A program to read employee data from the keyboard and print that data can be implemented in various programming languages. The following example demonstrates this using Python, a widely used and beginner-friendly language.
Explanation:
- This function prompts the user to enter employee details (ID, Name, Designation, Salary) using the
input()function. - The entered data is stored in a dictionary called
employee_data, where keys represent the data fields (e.g., 'id', 'name') and values are the user's input. - The function returns this
employee_datadictionary.
- This function prompts the user to enter employee details (ID, Name, Designation, Salary) using the
- This function takes a dictionary
data(expected to be theemployee_datadictionary) as an argument. - It then prints each piece of employee information in a formatted manner using f-strings for clear output.
- This function takes a dictionary
- This block ensures that the code inside it only runs when the script is executed directly (not when imported as a module).
- It calls
get_employee_data()to collect the employee information. - Finally, it calls
print_employee_data()to display the collected information.
కామెంట్లు లేవు:
కామెంట్ను పోస్ట్ చేయండి