0% found this document useful (0 votes)
6 views1 page

Python Programs for Data Management

The document contains three programming questions for a Python test. The first question involves creating a program to manage names and ages of individuals using a dictionary, while the second question focuses on developing a Course Enrollment System. The third question requires a program to print even numbers from a list until the number 237 is reached.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Python Programs for Data Management

The document contains three programming questions for a Python test. The first question involves creating a program to manage names and ages of individuals using a dictionary, while the second question focuses on developing a Course Enrollment System. The third question requires a program to print even numbers from a list until the number 237 is reached.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

​ ​ ​ ​ ​ Python Test

Question 1:- ​

●​ Write a Python program that:


1.​ Takes the names and ages of 5 people as user input.
2.​ Stores this information in a dictionary with names as keys and ages as values.
3.​ Displays the name of the oldest and youngest person.
4.​ Updates the age of a person based on user input.
5.​ Deletes a person from the dictionary based on user input.
6.​ Displays all the names in alphabetical order.

Question 2:-

●​ Create a Python program to manage a Course Enrollment System that allows Users
to
○​ Add courses
○​ Enroll students,
○​ View enrolled students by course,
○​ Generate a summary report of total courses and students.
○​ Record the date and time of enrollment and display it next to each student's
name.

Question 3:-

●​ Write a python program to print all even numbers from a given list of numbers in

the same order and stop printing any after 237 in the sequence.

Sample numbers list:

numbers = [ 386, 462, 47, 418, 907, 344, 236, 375, 823, 566, 597, 978, 328, 615, 953, 345,

399, 162, 758, 219, 918, 237, 412, 566, 826, 248, 866, 950, 626, 949, 687, 217, 815, 67, 104,

58, 512, 24, 892, 894, 767, 553, 81, 379, 843, 831, 445, 742, 717, 958,743, 527]

Common questions

Powered by AI

To effectively update user data in a Python dictionary, prompt the user for the specific key (name) whose value (age) they wish to update and assign the new value to this key. For deleting data, solicit user input for the key to remove and use the 'del' statement to remove the entry from the dictionary, ensuring to handle potential KeyError if the key doesn't exist .

A Python program for managing a Course Enrollment System should include features such as adding courses, enrolling students, viewing students by course, generating a summary report of total courses and students, recording the date and time of enrollment, and displaying these details next to each student's name .

Stopping print operations when a specific condition is met is important to control output and avoid unnecessary processing. For example, if printing even numbers from a list, stopping when reaching the number 237 ensures focus on relevant data and conserves computational resources .

A method to print all even numbers from a list until a specific value (237) is encountered involves iterating over the list, checking each number for evenness, and printing it if true. The process stops once the number 237 is reached, ensuring any subsequent numbers are ignored .

Implement a sorting mechanism in Python by using the 'sorted()' function on the dictionary keys. This function returns a list of dictionary keys sorted in alphabetical order, which can then be displayed to the user .

To find the oldest and youngest person in a dataset stored as a dictionary with names as keys and ages as values, you can use the built-in Python functions 'max()' and 'min()' to determine the maximum and minimum values in the dictionary, respectively, which correspond to the oldest and youngest ages .

Recording the date and time of enrollment and displaying it alongside each student's name is crucial for tracking when enrollments occur, understanding student registration patterns, providing transparency, and ensuring accurate record-keeping for administrative and auditing purposes .

Effectively integrating user input involves using 'input()' to solicit data, converting data types as necessary, utilizing loops for repeated operations, and providing user prompts to guide data entry. Ensuring validation of inputs prevents errors and maintains data integrity in dynamic datasets .

A dictionary is well-suited for storing course and student data due to its key-value structure, allowing efficient organization, retrieval, and modification of data. Courses can be keys with lists of enrolled students, facilitating easy updates and report generation .

To handle personal data using a Python program, start by collecting the names and ages of five people and store them in a dictionary. You should then display the names of the oldest and youngest individuals. Include functionality for updating and deleting an entry upon user input, and display all names in alphabetical order .

You might also like