0% found this document useful (0 votes)
7 views11 pages

20 Practical Python Coding Questions

The document contains 20 concise Python programming questions, each structured with an aim, variables used, coding examples, and expected outputs. Topics include checking even/odd numbers, calculating areas, converting temperatures, and string manipulations. The questions are designed to be practical and ready for implementation in a lab or notebook setting.

Uploaded by

yta1111111111
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)
7 views11 pages

20 Practical Python Coding Questions

The document contains 20 concise Python programming questions, each structured with an aim, variables used, coding examples, and expected outputs. Topics include checking even/odd numbers, calculating areas, converting temperatures, and string manipulations. The questions are designed to be practical and ready for implementation in a lab or notebook setting.

Uploaded by

yta1111111111
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

नीचे 20 एकदम छोटे + थोड़े conceptual Python questions दिए गए हैं। हर question practical-file format में है: Aim,

Variables Used, Coding, Output ✅

Q1. Check Even or Odd


Aim: To check whether a number is even or odd.

Variables Used: n

Coding:

n = int(input("Enter a number: "))


if n % 2 == 0:
print("Number is Even")
else:
print("Number is Odd")

Output:

Enter a number: 7
Number is Odd

Q2. Check Positive, Negative or Zero


Aim: To identify number type.

Variables Used: n

Coding:

n = int(input("Enter a number: "))


if n > 0:
print("Positive Number")
elif n < 0:
print("Negative Number")
else:
print("Zero")

1
Output:

Enter a number: -4
Negative Number

Q3. Largest of Two Numbers


Aim: To find the largest of two numbers.

Variables Used: a, b

Coding:

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))

if a > b:
print("First number is greater")
else:
print("Second number is greater")

Output:

Enter first number: 10


Enter second number: 25
Second number is greater

Q4. Square of a Number


Aim: To calculate square of a number.

Variables Used: n

Coding:

n = int(input("Enter a number: "))


print("Square =", n*n)

2
Output:

Enter a number: 6
Square = 36

Q5. Check Divisible by 5


Aim: To check divisibility by 5.

Variables Used: n

Coding:

n = int(input("Enter a number: "))


if n % 5 == 0:
print("Divisible by 5")
else:
print("Not divisible by 5")

Output:

Enter a number: 40
Divisible by 5

Q6. Sum of Two Numbers


Aim: To find sum of two numbers.

Variables Used: a, b, s

Coding:

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))
s = a + b
print("Sum =", s)

3
Output:

Enter first number: 12


Enter second number: 8
Sum = 20

Q7. Check Voting Eligibility


Aim: To check whether a person can vote.

Variables Used: age

Coding:

age = int(input("Enter age: "))


if age >= 18:
print("Eligible for voting")
else:
print("Not eligible for voting")

Output:

Enter age: 17
Not eligible for voting

Q8. Area of Square


Aim: To calculate area of a square.

Variables Used: side, area

Coding:

side = int(input("Enter side: "))


area = side * side
print("Area =", area)

4
Output:

Enter side: 5
Area = 25

Q9. Simple Interest


Aim: To calculate simple interest.

Variables Used: p, r, t, si

Coding:

p = int(input("Enter principal: "))


r = int(input("Enter rate: "))
t = int(input("Enter time: "))
si = (p*r*t)/100
print("Simple Interest =", si)

Output:

Enter principal: 1000


Enter rate: 5
Enter time: 2
Simple Interest = 100.0

Q10. Celsius to Fahrenheit


Aim: To convert temperature.

Variables Used: c, f

Coding:

c = float(input("Enter temperature in Celsius: "))


f = (c * 9/5) + 32
print("Temperature in Fahrenheit =", f)

5
Output:

Enter temperature in Celsius: 25


Temperature in Fahrenheit = 77.0

Q11. Print Numbers 1 to 5


Aim: To display numbers using loop.

Variables Used: i

Coding:

for i in range(1,6):
print(i)

Output:

1
2
3
4
5

Q12. Sum of First 5 Natural Numbers


Aim: To find sum using loop.

Variables Used: i, total

Coding:

total = 0
for i in range(1,6):
total += i
print("Sum =", total)

6
Output:

Sum = 15

Q13. Check Leap Year


Aim: To check leap year.

Variables Used: year

Coding:

year = int(input("Enter year: "))


if year % 4 == 0:
print("Leap Year")
else:
print("Not a Leap Year")

Output:

Enter year: 2024


Leap Year

Q14. Length of a String


Aim: To find length of string.

Variables Used: s

Coding:

s = input("Enter a string: ")


print("Length =", len(s))

Output:

7
Enter a string: Python
Length = 6

Q15. Reverse a String


Aim: To reverse a string.

Variables Used: s

Coding:

s = input("Enter a string: ")


print("Reversed string =", s[::-1])

Output:

Enter a string: code


Reversed string = edoc

Q16. Count from 1 to n


Aim: To print numbers till n.

Variables Used: n, i

Coding:

n = int(input("Enter limit: "))


for i in range(1, n+1):
print(i)

Output:

Enter limit: 3
1

8
2
3

Q17. Find ASCII Value


Aim: To display ASCII value.

Variables Used: ch

Coding:

ch = input("Enter a character: ")


print("ASCII value =", ord(ch))

Output:

Enter a character: A
ASCII value = 65

Q18. Convert String to Uppercase


Aim: To convert string case.

Variables Used: s

Coding:

s = input("Enter a string: ")


print([Link]())

Output:

Enter a string: hello


HELLO

9
Q19. Check Palindrome Number
Aim: To check palindrome.

Variables Used: n

Coding:

n = input("Enter number: ")


if n == n[::-1]:
print("Palindrome")
else:
print("Not Palindrome")

Output:

Enter number: 121


Palindrome

Q20. Print Hello 5 Times


Aim: To display message using loop.

Variables Used: i

Coding:

for i in range(5):
print("Hello")

Output:

Hello
Hello
Hello
Hello
Hello

10
✔️ All questions are short, conceptual, and practical-ready ✔️ Directly copy to notebook / lab file

11

You might also like