0% found this document useful (0 votes)
4 views20 pages

Python Problem-Solving Guide

The document outlines steps for solving programming problems, including understanding the problem, writing an algorithm, and translating it into code. It presents various programming tasks, such as comparing ages, calculating statistics from test scores, and managing student records using dictionaries. Additionally, it emphasizes the importance of structured problem-solving and includes a quote by Grace Hopper.

Uploaded by

abduslexus
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)
4 views20 pages

Python Problem-Solving Guide

The document outlines steps for solving programming problems, including understanding the problem, writing an algorithm, and translating it into code. It presents various programming tasks, such as comparing ages, calculating statistics from test scores, and managing student records using dictionaries. Additionally, it emphasizes the importance of structured problem-solving and includes a quote by Grace Hopper.

Uploaded by

abduslexus
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

Click to edit Master title style

Python Practice

.
1
Steps to solve problems
Click to edit Master title style
U n d e r s t a n d T h e P r o b l e m
 Identify the input.
 Identify the output.
 Identify the process to change the input to the output (the solution).
Wr i t e t h e a l g o r i t h m .
 Here the steps are very important
 Remember our program executes step by step
Tr a n s l a t e i t s a l g o r i t h m t o c o d e ( M a p p i n g t h e
algorithm to a program)

2 2
Problem 1 Master title style
Click to edit
Write the Out put

3 3
Problem 2 Master title style
Click to edit
Write the Out put

4 4
Problem 3 Master title style
Click to edit
Write the Out put

5 5
Problem 4 Master title style
Click to edit

 Create a program that asks the user to enter their age and
their sibling's age. The program should compare the two
Write the valid Code

ages and display whether the user is older, younger, or if


they are twins. Additionally, if there is an age difference
(they are not twins), display the exact number of year
difference on the same line as the result.

6 6
Problem 5 Master title style
Click to edit
Write the Out put

7 7
Problem 6 Master title style
Click to edit
Fix error & write the
Output

8 8
Problem 7 Master title style
Click to edit
Write the Out put

9 9
Problem 8 Master title style
Click to edit
Write the Out put

10 10
Problem 9 Master title style
Click to edit

 Create a program that accepts five test scores as input, then


calculates and displays their total sum, average (rounded to two
Write the valid Code

decimal places), minimum value, and maximum value.

11 11
Problem 10 Master title style
Click to edit
Write the Out put

12 12
Problem 11 Master title style
Click to edit

Evaluate the following:


Write the Out put

13 13
Problem 12 Master title style
Click to edit
 Suppose that there is a list which contains the ID number, mid and final marks of
five students. The program uses a dictionary where the key is the ID of the
student and the value is a list containing the mid-exam mark (out of 40) and the
Write the code

final-exam mark (out of 60) of the student, like this

14 14
Problem 13 Master title style
Click to edit

 Create a program that stores information for five students in a


dictionary structure. Each student record should include their
Write the valid Code

name, age, class, and a list of their scores. Implement a function


that calculates and displays each student's average score, then
create another function that identifies and prints the top three
students based on their average scores.

15 15
Problem 14 Master title style
Click to edit

 Open a file '[Link]' (assume it has integers one per line),


Write the valid Code

Read the lines


Convert to integer
Print the sum of all numbers and write it at end of the file

16 16
Problem 15 Master title style
Click to edit
Write the Out put

17 17
Problem 16 Master title style
Click to edit

 Write a code that takes in two inputs, price and discount percent
and the calculate the discounted price rounds it to two decimal
Write the valid Code

places and then prints that out

18 18
Click to edit Master title style


“ The most dangerous phrase
in the language is, 'We've
always done it this way.”
― Grace Hopper

19 19
Click to edit Master title style

Thank You
20

You might also like