0% found this document useful (0 votes)
5 views2 pages

Python Practice Programs: Q1-Q10 Solutions

Uploaded by

pt.amanpandit01
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)
5 views2 pages

Python Practice Programs: Q1-Q10 Solutions

Uploaded by

pt.amanpandit01
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

Python Practice Programs (Sample: Q1 - Q10)

Q1. Check if a number is positive or negative.


num = int(input("Enter a number: "))
if num > 0:
print("Positive")
elif num < 0:
print("Negative")
else:
print("Zero")
■ Agar number 0 se bada hai to Positive, 0 se chhota hai to Negative, aur barabar 0 hai to
Zero.

Q2. Check if a number is even or odd.


num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even")
else:
print("Odd")
■ % ka matlab remainder hota hai. Agar remainder 0 hai to Even otherwise Odd.

Q3. Find the largest of two numbers.


a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
if a > b:
print("Largest:", a)
elif b > a:
print("Largest:", b)
else:
print("Both are equal")
■ if-else use karke compare karte hain. Greater number ko print kar diya.

Q4. Check if a number is divisible by 5.


num = int(input("Enter a number: "))
if num % 5 == 0:
print("Divisible by 5")
else:
print("Not divisible by 5")
■ Agar number 5 se divide hone par remainder 0 deta hai to divisible by 5.

Q5. Check if a number is divisible by both 3 and 7.


num = int(input("Enter a number: "))
if num % 3 == 0 and num % 7 == 0:
print("Divisible by 3 and 7")
else:
print("Not divisible by both")
■ Dono condition true hone par hi divisible by both.

Q6. Check if a person is eligible to vote (age ≥ 18).


age = int(input("Enter age: "))
if age >= 18:
print("Eligible to vote")
else:
print("Not eligible")
■ Voting ke liye minimum age 18 years honi chahiye.

Q7. Check if a number is single-digit, double-digit, or more.


num = int(input("Enter a number: "))
if -9 <= num <= 9:
print("Single-digit")
elif -99 <= num <= 99:
print("Double-digit")
else:
print("More than two digits")
■ Range ke basis par digit check kiya.

Q8. Check if a number is zero, positive, or negative.


num = int(input("Enter a number: "))
if num > 0:
print("Positive")
elif num < 0:
print("Negative")
else:
print("Zero")
■ Simple conditions se check karte hain.

Q9. Check if a number is a multiple of 10.


num = int(input("Enter a number: "))
if num % 10 == 0:
print("Multiple of 10")
else:
print("Not a multiple of 10")
■ Agar remainder 0 aata hai divide karne par, iska matlab multiple of 10 hai.

Q10. Check if a string entered by the user is empty or not.


s = input("Enter a string: ")
if s == "":
print("Empty string")
else:
print("Not empty")
■ Agar string ki length 0 hai to wo empty hai.

You might also like