-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample programs.py
More file actions
50 lines (44 loc) · 1.21 KB
/
example programs.py
File metadata and controls
50 lines (44 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
n = int(input("Enter a number between 1 and 10: "))
if n == 1:
print(1)
elif n == 2:
print(2)
elif n == 3:
print(3)
elif n == 4:
print(4)
elif n == 5:
print(5)
elif n == 6:
print(6)
elif n == 7:
print(7)
elif n == 8:
print(8)
elif n == 9:
print(9)
elif n == 10:
print(10)
# take two inputs from user and print their sum
a=int(input("Enter number 1:"))
b=int(input("Enter number 2:"))
print("sum:",a+b)
#Ask name and age and print formatted greeting.
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("your name is ",name," and your age is ",age)
#Convert kilometers to miles.
km=int(input("Enter distance in km:"))
print("Distance in miles is:",km*0.6)
#Compute area of a triangle.
base = float(input("Enter the base of the triangle: "))
height = float(input("Enter the height of the triangle: "))
area = 0.5 * base * height
print("The area of the triangle is:", area)
#Print type of each variable entered by user.
var1 = input("Enter first variable: ")
var2 = input("Enter second variable: ")
var3 = input("Enter third variable: ")
print("Type of first variable:", type(var1))
print("Type of second variable:", type(var2))
print("Type of third variable:", type(var3))