#Program to add first 5 natural numbers
sum = 0
a=1
while (a<=5):
sum = sum + a
a=a+1
print("The sum of first five natural num is", sum)
#Program to grade a student based on his/her marks
marks = int(input("Enter your marks: "))
if (marks >= 90):
print("A grade")
elif (marks >= 80):
print("B grade")
elif (marks >= 70):
print("C grade")
elif (marks >= 60):
print("D grade")
elif (marks >= 50):
print("You can do better")
else:
print("You need to work hard")
#Program to check greatest of the three numbers
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
num3 = int(input("Enter the third number: "))
if num1 > num2:
if num1 > num3:
print("Num1 is greatest Number ;", num1)
else:
print("Num3 is greatest Number ;", num1)
else:
if num2 > num3:
print("Num2 is greatest Number ;", num2)
else:
print("Num3 is greatest Number ;", num3)
print("Num3 is greatest Number ;", num1)
#To check whether the entered number is even or odd
n = int(input("Enter your number: "))
if (n%2) == 0:
print("The entered number is even")
else:
print("The entered number is odd")
#To check whether a person can vote
age = 18
if (age<18):
print ("You are eligible to cast your vote")
else:
print ("You are not eligible to cast your vote")
#To check whether the given number is greater than zero.
n =int(input("Enter a Number: "))
if n > 0:
print ("The entered number is greater than 0")
else:
print("The entered number is smaller than 0")
# Python program to print Even Numbers in given range
Start = int(input("Enter the start of range: "))
end = int(input("Enter the end of range: "))
# iterating each number in list
for num in range(start, end + 1):
# checking condition
if num % 2 == 0:
print(num, end=" ")
# Program to check whether the number is positive or negative
a = int(input("Enter the number to test: "))
if (a>0):
else:
print("The given number is a negative number")
# Program to generate a list from 1-20
for n in range(1, 21):
print(n)’