0% found this document useful (0 votes)
25 views

Submitted By: Submitted To

The document is an assignment submission containing code snippets and outputs for 4 questions. It includes the student's name, ID, course details and date of submission. Question 1 converts an age to the year the person will turn 100. Question 2 prints a nursery rhyme. Question 3 compares a random number to a user guess. Question 4 converts a decimal to binary, octal and hexadecimal.

Uploaded by

Sanjeev Gyawali
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)
25 views

Submitted By: Submitted To

The document is an assignment submission containing code snippets and outputs for 4 questions. It includes the student's name, ID, course details and date of submission. Question 1 converts an age to the year the person will turn 100. Question 2 prints a nursery rhyme. Question 3 compares a random number to a user guess. Question 4 converts a decimal to binary, octal and hexadecimal.

Uploaded by

Sanjeev Gyawali
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
You are on page 1/ 4

Programme Name:BCS

Course Code: CSC 3530


Course Name: Advanced programming
Assignment. 1st
Date of Submission: 12/2/2020

Submitted By: Submitted To:

Student Name:Sanjeev gyawali Faculty Name:Amar Subedi

IUKL ID:041802900038 Department: computer science

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:-

You might also like