Professional Documents
Culture Documents
Submitted By: Submitted To
Submitted By: Submitted To
Semester:4th
Intake:sept 2018
Question no 1
Code:-
from datetime import datetime
name=input("Enter you name:")
age=int(input("Enter age:"))
fyear=int((100-age) + datetime.now().year)
print(fyear)
print ('Hello %s. You are %s years old. You will turn 100 years old in
%s.' %(name,age,fyear))
Output:-
Question no 2
Code:-
print("Twinkle, twinkle, little star,\n \tHow I wonder what you are!\n
\t\tUp above the world so high,\n \t\tLike a diamond in the sky.\n Tw
inkle, twinkle, little star,\n How I wonder what you are")
Output:-
Question no 3
Code:-
import random
a=int(input("Enter your guess:"))
b=random.randint(1,9)
if a==b:
print("Well!guess")
else:
print("your guess is not right")
Question 4
Code:-
dec = int(input("Enter a decimal number: "))
print(bin(dec),"in binary.")
print(oct(dec),"in octal.")
print(hex(dec),"in hexadecimal.")
Output:-