1. Python Practice Problems
K. Narsimlu (IT-Mentor)
Python Practice Problems: (Simple Programs)
In the following problems use input command. Ask the user to enter ‘a’ and ‘b’ values
and you have to find out ‘c’ value (use raw_input to get input data from key board):
1. Write a Python Program to print the following values
a. Ex1: a=2, b=3, output c=5
b. Ex2: a=45, b=80, output c=125
2. Write a Python Program to concatenate twostrings
a. Ex1: string1=RGUKT string2=Basar, resultc=RGUKTBasar
3. Write a Python Program to print the following values
a. Ex1: a=7, b=4 output c=65
b. Ex2: a=8, b=2 output c=68
4. Write a Python Program to print the following values
a. Ex1: a= 45, b=6 output c=3
b. Ex1: a=11, b=2 output c=1
5. Write a Python Program to print the following values
a. Ex1: a=225, b=15 output c=15
b. Ex2: a=41 , b=5 output c=8
6. Write a Python Program to print the following values
a. Ex1: a=7, b=8 output c=225
b. Ex1: a=15, b=30 output c=2025
7. Write a Python Program to print the following values
a. Ex1: a=113 output is 10.63
b. Ex2: a=55 output is 7.41
8. Write a Python Program to print the following values
a. Ex1: a=45 b=114 output is a=114, b=45
9. Write a Python Program to print the following values
a. Ex1: a=345, b=230 output c = 460
b. Ex2: a=45, b=330 output c = 660
10. Design your own signature logo and print it followed by “yours truly—your name.”
a. A signature logo might look like
2. Python Practice Problems
K. Narsimlu (IT-Mentor)
Complex Programs:
1. Write a Python Program to ask the user to enter one integer. If the entered number
is even. Print the given number is even or Print the given number is odd
2. Write a Python Program to ask the user to enter his age. If the age is greater than
or equals to 18 then print a message “He/ she is a major”. If the age is less than
18, then print a message that “he/she is minor”.
3. Write a Python Program to ask the user to enter two numbers. And find out the bigger
number. Ex: number1=50, number2=100. The output should be “Number2 is bigger”. If
the two numbers are equal , print a message that “Two numbers are equal”
4. Write a program, ask for the user to enter five integer values and calculate the average.
5. You have a green lottery ticket, with ints a, b, and c on it. If the numbers are all
different from each other, the result is 0. If all of the numbers are the same, the
result is 20. If two of the numbers are the same, the result is 10.
TestCases:
greenTicket(1,2,3)→0
greenTicket(2,2,2)→20
greenTicket(1, 1, 2) →10