0% found this document useful (0 votes)
3 views7 pages

? Integrated Python Practice Questions

The document outlines a series of integrated Python practice questions designed to enhance programming skills through various scenarios, including student marks analysis, multiplication table generation, shape calculations, prime number checks, shopping cart management, temperature logging, and quiz score tracking. Each scenario includes specific requirements, user inputs, and expected outputs to guide learners in implementing solutions using lists, dictionaries, sets, and control flow. The exercises aim to provide hands-on experience with fundamental programming concepts and data structures.

Uploaded by

kasiryefavour7
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

? Integrated Python Practice Questions

The document outlines a series of integrated Python practice questions designed to enhance programming skills through various scenarios, including student marks analysis, multiplication table generation, shape calculations, prime number checks, shopping cart management, temperature logging, and quiz score tracking. Each scenario includes specific requirements, user inputs, and expected outputs to guide learners in implementing solutions using lists, dictionaries, sets, and control flow. The exercises aim to provide hands-on experience with fundamental programming concepts and data structures.

Uploaded by

kasiryefavour7
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

🧮 Integrated Python Practice Questions with Test Input & Output

1. Student Marks Analyzer

Scenario: A school wants a program to store students’ marks in three subjects and calculate their average, highest
mark, and grade.

Requirements:

1. Ask the user for the number of students.

2. For each student:

o Input their name and marks for Math, English, and Science.

o Store marks in a dictionary with subject names as keys.

o Store all student dictionaries in a list.

3. Use lists, and dictionaries to:

o Calculate the average mark.

o Find the highest mark.

4. Use control flow to assign grades, use the average:

o A: ≥80, B: 70–79, C: 60–69, D: 50–59, F: <50

5. Store all grades in a set (to see unique grades awarded).

6. Display each student’s name, marks, average, highest mark, and grade.

Test Input:

Code

Enter number of students: 2

Enter name: Alice

Math: 85

English: 78

Science: 92

Enter name: Bob

Math: 60

English: 55

Science: 70

Expected Output:

Code
--- Student Report ---

Name: Alice

Marks: {'Math': 85, 'English': 78, 'Science': 92}

Average: 85.00

Highest Mark: 92

Grade: A

Name: Bob

Marks: {'Math': 60, 'English': 55, 'Science': 70}

Average: 61.67

Highest Mark: 70

Grade: C

Unique Grades: {'A', 'C'}

2. Multiplication Table Generator with Conditions

Scenario: Generate multiplication tables for a given range of numbers.

Requirements:

1. Ask the user for a start and end number.

2. Use nested loops to generate multiplication tables for each number in the range.

3. Skip any multiplication where the result is divisible by 5 (continue).

4. Stop generating tables entirely if the number is greater than 12 (break).

5. Store all results in a dictionary where the key is the number and the value is a list of results.

6. Use math for multiplication.

Test Input:

Code

Enter start number: 2

Enter end number: 4

Expected Output (truncated for brevity):

Code
2x1=2

2x2=4

2x3=6

2x4=8

2 x 6 = 12

...

4 x 9 = 36

4 x 10 = 40 (skipped - divisible by 5)

...

Results Dictionary: {2: [2, 4, 6, 8, 12, 14, 16, 18], 3: [...], 4: [...]}

3. Circle and Rectangle Calculator

Scenario: Calculate the area and perimeter of shapes.

Requirements:

1. Ask the user to choose a shape: "circle" or "rectangle".

2. If "circle":

o Input radius.

o Use [Link] and [Link]() to calculate area and circumference.

3. If "rectangle":

o Input length and width.

o Calculate area and perimeter.

4. Store results in a dictionary with keys "area" and "perimeter".

5. Add all calculated areas to a set to track unique areas.

6. Use a loop to allow multiple calculations until the user types "exit".

Test Input:

Code

Enter shape (circle/rectangle/exit): circle

Enter radius: 7

Enter shape (circle/rectangle/exit): rectangle

Enter length: 5
Enter width: 3

Enter shape (circle/rectangle/exit): exit

Expected Output:

Code

Circle: {'area': 153.94, 'perimeter': 43.98}

Rectangle: {'area': 15.00, 'perimeter': 16.00}

Unique Areas: {153.94, 15.0}

4. Prime Number and Factorial Finder

Scenario: Check if a number is prime and calculate its factorial.

Requirements:

1. Input a number from the user.

2. Use a loop to check if it’s prime.

3. If prime, calculate factorial using [Link]().

4. Store results in a dictionary: {"number": n, "is_prime": True/False, "factorial": value}

5. Keep a set of all prime numbers entered so far.

6. Repeat until the user enters 0.

Test Input:

Code

Enter number: 5

Enter number: 4

Enter number: 0

Expected Output:

Code

{'number': 5, 'is_prime': True, 'factorial': 120}

{'number': 4, 'is_prime': False, 'factorial': None}

Prime Numbers Set: {5}

5. Shopping Cart System

Scenario: Manage a shopping cart.

Requirements:
1. Use a dictionary to store items and their prices.

2. Use a set to store unique categories of items.

3. Allow the user to:

o Add items (name, price, category).

o Remove items.

4. Use a loop to keep asking until "checkout".

5. At checkout:

o Calculate total price using [Link]().

o Apply a 10% discount if total > 100.

6. Display all items, categories, and final total.

Test Input:

Code

Enter action (add/remove/checkout): add

Item name: Apples

Price: 50

Category: Fruits

Enter action (add/remove/checkout): add

Item name: Milk

Price: 60

Category: Dairy

Enter action (add/remove/checkout): checkout

Expected Output:

Code

Items: {'Apples': 50.0, 'Milk': 60.0}

Categories: {'Fruits', 'Dairy'}

Total before discount: 110.0

Discount applied: 10%

Final Total: 99.0

6. Temperature Data Logger


Scenario: Log daily temperatures.

Requirements:

1. Ask the user for the number of days.

2. For each day:

o Input temperature in Celsius.

o Convert to Fahrenheit using: F = C * (9/5) + 32

3. Store both Celsius and Fahrenheit in a dictionary.

4. Keep a set of all unique Fahrenheit values.

5. Use loops to:

o Find the highest and lowest temperatures.

o Calculate the average using [Link]().

Test Input:

Code

Enter number of days: 3

Day 1 temperature (C): 25

Day 2 temperature (C): 30

Day 3 temperature (C): 28

Expected Output:

Code

Temperatures: {1: {'C': 25, 'F': 77.0}, 2: {'C': 30, 'F': 86.0}, 3: {'C': 28, 'F': 82.4}}

Unique Fahrenheit Values: {77.0, 86.0, 82.4}

Highest Temp (C): 30

Lowest Temp (C): 25

Average Temp (C): 27.67

7. Quiz Score Tracker

Scenario: Track player scores.

Requirements:

1. Ask the user for the number of players.

2. For each player:


o Input name and 5 quiz scores.

o Store scores in a list inside a dictionary.

3. Use a loop to calculate:

o Average score.

o Highest score.

4. Store all averages in a set.

5. Use control flow to give feedback:

o "Excellent" if average ≥80

o "Good" if 60–79

o "Needs Improvement" if <60

Test Input:

Code

Enter number of players: 2

Name: Alice

Scores: 90 85 88 92 87

Name: Bob

Scores: 60 65 58 62 64

Expected Output:

Code

Alice → Avg: 88.4, Highest: 92, Feedback: Excellent

Bob → Avg: 61.8, Highest: 65, Feedback: Good

Unique Averages: {88.4, 61.8}

You might also like