-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput programs in python
More file actions
180 lines (138 loc) · 3.82 KB
/
Copy pathInput programs in python
File metadata and controls
180 lines (138 loc) · 3.82 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
PROG#1
#taking user input numbers, giving sorted even or odd numbers.
num=input("enter a list of numbers= ").split()
even_num=[]
odd_num=[]
for n in num:
m=int(n)
if m%2==0:
even_num.append(m)
else:
odd_num.append(m)
print(f"{even_num} = even")
print(f"{odd_num} = odd")
PROG#2
#area of circle
import math
r=int(input("enter radius of circle: "))
A= math.pi *(r*r)
print(f"given radius={r},area of circle is calculated as {A}")
PROG#3
#area of parallelogram
b=int(input("enter base of parallelogram: "))
h=int(input("enter height of parallelogram: "))
A=b*h
print(f"given base={b} and height={h}, area of parallelogram is calculated as {A}")
PROG#4
#calculate area of rectangle
l=int(input("enter length of rectangle: "))
w=int(input("enter width of rectangle: "))
a=l*w
print(f"given length {l} and given width {w} , area of rectangle is {a}")
PROG#5
#area of square
a=int(input("enter a side of square: "))
A=a*a
print(f"given side={a},area of square is calculated as {A}")
PROG#6
#area of triangle
b=int(input("enter base of triangle: "))
h=int(input("enter perpendicular height of triangle: "))
A=1/2 * (b*h)
print(f"given base={b} and height={h},area of triangle is calculated as {A}")
PROG#7
#arithmetic all operators
x=int(input("enter first operand: "))
y=int(input("enter second operand: "))
z=x+y
t=x-y
n=x*y
m=x/y
u=x%y
v=x**y
b=x//y
print(f"sum of {x} and {y} is={z}")
print()
print(f"difference of {x} and {y} is={t}")
print()
print(f"multiplication of {x} and {y} is={n}")
print()
print(f"division of {x} and {y} is={m}")
print()
print(f"modulus of {x} and {y} is={u}")
print()
print(f"exponential of {x} raise to the power {y} is={v}")
print()
print(f"floor division of {x} and {y} is={b}")
PROG#8
#fahrenheit to celsius unit conversion
c=int(input("enter temperature in celcius: "))
f=c*(9/5)+32
print(f"{c} celsius is = {f} fahrenheit")
PROG#9
#comparison operators
x=int(input("enter first operand: "))
y=int(input("enter second operand: "))
z= x==y
p= x!=y
q= x>y
r= x<y
s= x>=y
t= x<=y
print(f"given first operand,{x} and second operand,{y} are equal {z}")
print(f"given first operand,{x} and second operand,{y} are not equal {p}")
print(f"given first operand,{x} is greater than second operand,{y} {q}")
print(f"given first operand,{x} is less than second operand,{y} {r}")
print(f"given first operand,{x} is greater than or equal to second operand,{y} {s}")
print(f"given first operand,{x} is less than or equal to second operand,{y} {t}")
PROG#10
#fahrenheit to celsius unit conversion
f=int(input("enter temperature in fahrenheit: "))
c=(f-32)*(9/5)
print(f"{f} fahrenheit is = {c} celsius")
PROG#11
#logical operators
x=int(input("enter first operand: "))
y=int(input("enter second operand: "))
f=x>10 and y>10
t=x>10 or y>10
u=not(x>10 and y>10)
print(f"both operand {x} and {y} is greater than 10 {f}")
print(f"either first operand {x} or second operand {y} are greater than 10 {t}")
print(f"giving opposite result i.e {u}, when {x} any {y} are greater than 10")
PROG#12
employees={
"Emp1":{"name": "Alice","role": "Engineer"},
"Emp2": {"name": "Bob","role": "Designer"},
"Emp3": {"name": "Charlie","role": "Manager"},
}
for emp_id,details in employees.items():
print()
print(f"ID:{emp_id}")
for key,value in details.items():
print(f"{key}:{value}")
PROG#13
students ={
"Ayesha":{
"age":21,
"grades":{
"math":90,
"physics":85,
"chemistry":88
}
},
"Bilal":{
"age":22,
"grades":{
"math":75,
"physics":80,
"chemistry":70
}
}
}
for name,info in students.items():
print()
print(f"{name}:")
print(f"Age:{info["age"]}")
for key,value in info["grades"].items():
print(f"{key}:{value}")