Register for Updates

Practise Problems on Python

Begin

Write a program to print your name ten times.

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

Question 1

Write a program to print numbers from 1 to 10 using for loop.

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

Question 2

Write a program to print numbers from 100 to 200 using for loop.

for i in range(100,201):
  print(i)
              

Question 3

Write a program to print numbers between 1 to 100 at the interval of 5 using for loop.

for i in range(1,100,5):
  print(i)
              

Question 4

Write a program to print numbers between 1 to 100 at the interval of 3 using for loop.

for i in range(1, 100,3):
  print(i)
              

Question 5

Write a program to print the table of 2.

for i in range(1, 11):
  print(2*i)
              

Question 6

Write a program to print the table of 17.

for i in range(1, 11):
  print(17*i)
              

Question 7

Write a program to print a number 5, ten times.

for i in range(10):
  print(5)
              

Question 8

If a=2 and b=3, check whether it is a square or not, using the if/else condition.

a=2;
b=3;
if a==b:
  print("it is a square")
else:
  print("it is not a square")
              

Question 9

If a=5 and b=10, write a program to print the greatest among them.

a=5;
b=10;
if a>b:
  print("a is greater")
elif a==b:
  print("both a and b are equal")
else:
  print("b is greater")
              

Question 10

Take two values from the user and write a program to print a larger number.

a=float(input("enter 1st number"))
b=float(input("enter 2nd number"))
if a>b:
  print("a is larger")
elif a==b:
  print("both a and b are equal")
else:
  print("b is larger")
              

Question 11

Take three distinct values from the user using the input command and write a program to print the largest number.

a=float(input("enter 1st number"))
b=float(input("enter 2nd number"))
c=float(input("enter 3rd number"))
if a>b and a>c:
  print("a is largest")
elif b>a and b>c:
  print("b is largest")
else:
  print("c is largest")
              

Question 12

Take two values from the user using the input command and check if they are equal.

a=float(input("enter 1st number"))
b=float(input("enter 2nd number"))
if a==b:
  print("numbers are equal")
else:
  print("numbers are not equal")
              

Question 13

Take three values from the user using the input command and write a program to check whether they are equal or not.

a=float(input("enter 1st number"))
b=float(input("enter 2nd number"))
c=float(input("enter 3rd number"))
if a==b and a==c:
  print("numbers are equal")
else:
  print("numbers are not equal")
              

Question 14

Ask the name of the user using input command and print "hello name".

name=input("enter your number")
print(" Hello " + name)
              

Question 15

Ask the name and the gender from a user and if the user is a male then print "Hello Mr Name", else if the user is a female then print "Hello Miss Name"

name=input("enter your name")
gender=input("are you a male or female")
if gender=="male":
  print(" Hello Mr. "+ name)
else:
  print(" Hello Miss " + name)
              

Question 16

Write a program to print your name infinitely.

while True:
  print("name")
              

Question 17

Ask user to enter age and print whether the user is elligible for voting or not, considering the user is eligible to vote if the age is 18 or more.

age=float(input("enter your age"))
if age>=18:
  print("you can vote")
else:
  print("you can not vote")
              

Question 18

Write a program to print numbers between 1 to 100 which are divisible by 3.

for i in range(1,101):
  if i%3==0:
    print(i)
              

Question 19

Write a program to print numbers between 1 to 100 which are divisible by 3 and 5.

for i in range(1,101):
  if i%3==0 and i%5==0:
    print(i)
              

Question 20

Write a program to ask the age of the user infinitely and the program should break only if the age of the user is 25.

while True:
  age=float(input("enter your age"))
  if age==25:
    break