Python Practice Problems (Beginner → Intermediate)
A. Say Hello
Problem: Write a program that reads a name and prints 'Hello, '.
Input:
Sourabh
Output:
Hello, Sourabh
B. Basic Data Types (Python Version)
Problem: Read four values: (1) An integer, (2) A character, (3) A float, (4) A string.
Input:
5
A
3.14
Hello
Output:
5
A
3.14
Hello
C. Simple Calculator
Problem: Read two integers a and b. Print their sum, difference, product, and quotient (integer
division).
Input:
10 3
Output:
13
7
30
3
D. Difference
Problem: Given four integers a, b, c, d, print (a * b) - (c * d).
Input:
5678
Output:
-26
E. Area of a Circle
Problem: Read a radius r and print the area of the circle using π = 3.141592653.
Input:
3
Output:
28.274333877
F. Digits Summation
Problem: Read two integers. Print the sum of their last digits.
Input:
245 36
Output:
11
G. Summation from 1 to N
Problem: Read integer n. Print the summation 1 + 2 + ... + n.
Input:
5
Output:
15
H. Two Numbers
Problem: Read two integers a and b. Print integer division (a // b) and remainder (a % b).
Input:
10 3
Output:
31
I. Welcome with Conditions
Problem: Read two integers a and b. Print 'Yes' if a >= b, else 'No'.
Input:
57
Output:
No
J. Multiples
Problem: Read two integers a and b. Print 'Multiples' if one divides the other, else 'No Multiples'.
Input:
63
Output:
Multiples
K. Max and Min
Problem: Read two integers and print them in ascending order.
Input:
10 3
Output:
3 10
L. The Brothers
Problem: Read two names (first + last) for two people. If last names match, print 'ARE Brothers'.
Else 'NOT'.
Input:
John Smith
Alex Smith
Output:
ARE Brothers
M. Capital or Small or Digit
Problem: Read a character. Print whether it is Capital letter, Small letter, or Digit.
Input:
A
Output:
Capital letter
N. Char
Problem: Read a character. If lowercase → uppercase. If uppercase → lowercase.
Input:
a
Output:
A
O. Calculator
Problem: Read two numbers and an operator (+, -, *, /). Perform the operation.
Input:
53+
Output:
8
P. First Digit!
Problem: Read a number. Print its first digit.
Input:
98765
Output:
9
Q. Coordinates of a Point
Problem: Given point (x, y), print its location: Quadrant 1,2,3,4 or Origin.
Input:
3 -4
Output:
Quadrant 4
R. Age in Days
Problem: Given total days d. Convert into years, months, days (1 year=365, 1 month=30).
Input:
400
Output:
1 years
1 months
5 days
S. Interval
Problem: Read a number. Print which interval it belongs: [0,25], (25,50], (50,75], (75,100]. Else 'Out
of Intervals'.
Input:
35
Output:
(25,50]
T. Sort Numbers
Problem: Read 3 integers. Print them in ascending order.
Input:
729
Output:
279
U. Float or Int
Problem: Read a number. Print 'Integer' if no decimals, else 'Float'.
Input:
12.5
Output:
Float
V. Comparison
Problem: Read two integers a, b. Print <, >, or = depending on relation.
Input:
49
Output:
<
W. Mathematical Expression
Problem: Read three integers a, b, c. Print 'Yes' if a+b=c or a-b=c or a*b=c or a/b=c. Else 'No'.
Input:
3 4 12
Output:
Yes
X. Two Intervals
Problem: Read two intervals [l1, r1], [l2, r2]. Print their intersection, else -1.
Input:
15
47
Output:
45
Y. The Last 2 Digits
Problem: Read a, b. Print last two digits of a^b.
Input:
3 10
Output:
49
Z. Hard Compare
Problem: Read four integers a, b, c, d. Compare a^b with c^d. Print >, <, or =.
Input:
2 10 4 5
Output:
=