Posts

Showing posts from June, 2017

Python program to reverse user defined value using function.

#Fucntion that reverse userdefined value. N = int(input("Enter Number to reverse: ")) def REVERSE():     global N     Rev = 0     O = N     while N != 0 :         Rev = Rev * 10         Rev = Rev + (N%10)         N = N // 10     print("Reverse of %d"% O,"is: %d" % Rev)     return REVERSE()

Python program to generate the Febonacci series.

#Program to generate the Febonacci series. N = input("Enter Number of terms you want to print: ") N = int(N) F1 = 0 F2 = 1 i = 3 print(F1) print(F2) for i in range(N-2) :     F3 = F1+F2     print(F3)     F1=F2     F2=F3

Python program to check whether the given number is even or odd.

#Program that will check whether entered number is even or odd. N = input("Enter Number to check: ") N = int(N) if N%2 == 0:     print("%d is an even number."% N) else:     print("%d is an odd number."% N)

Python program to calculate age and year when user will be 100 years old

#Program that will ask user his name and his date of birth and print his age and year when he will turn 100 years old. #to enter your date use format like 8-8-1996 import datetime name = input("Enter your name: ") today = datetime.date.today() birthIn = input("Enter your Birhtday in format Date-Month-Year: ") birthday = datetime.datetime.strptime(birthIn, "%d-%m-%Y") print("Todays date is:", today.strftime("%d-%m-%Y")) print("Your Birthday is on: ", birthIn) age = today.year-birthday.year print(name +" your age is: ",age) old = (100-age)+today.year print("In %d you will be 100 years old" % old)