1
Variable, Operator and Expression
2
[ Assignment : Set – 1]
1. Write a program that asks the user for his name and then welcomes him. The output should
look like this:
Enter your name: Saksham
Hello Saksham
Solution
).
2. Write a program that prompts the user to enter two integers and display their sum on the
02
screen. Solution
3. Write a program that prompts the user to input a Celsius temperature and outputs the
C4
equivalent temperature in Fahrenheit. The formula to convert the temperature is: F = 9/5 C
+ 32 where F is the Fahrenheit temperature and C is the Celsius temperature. Solution
C
4. Write a program which accept principle, rate and time from user and print the simple interest.
(B
The formula to calculate simple interest is: simple interest = principle x rate
x time / 100 Solution
g_
5. Write a program that accepts seconds from keyboard as integer. Your program should
in
converts seconds in hours, minutes and seconds. Your output should like this :
m
Enter seconds: 13400
m
Hours: 3
Minutes: 43
ra
Seconds: 20 Solution
6. Write a program that prompts the user to enter number in two variables and swap the
og
contents of the variables. Solution
Pr
7. Write a program that prompts the user to enter number in two variables and swap the
contents of the variables.(Do not declare extra variable.) Solution
on
8. Write a program that prompts the user to input the radius of a circle and outputs the area and
circumference of the circle. The formula is
th
Area = pi x radius2
Py
Circumference = 2 x pi x radius Solution
9. Write a program that prompts the user to input the length and the width of a rectangle and
outputs the area and perimeter of the rectangle. The formula is
Area = Length x Width
Circumference = 2 x ( Length + Width) Solution
10. Write a program which prompts the user to input principle, rate and time and calculate
compound interest. The formula is :
CI = P(1+R/100)^T - P Solution
1
Note: Use Python Shell and paste screenshots of the code and output
2
Note: Try to solve it yourself first.