Tuple and Dictionary
Tuple and Dictionary
Output:
============= RESTART: C:\Users\vijay\OneDrive\Desktop\3.py ============
Enter student details((101,"stu1",89),(102,"stu2",78))
roll name marks
101 stu1 89
102 stu2 78
r=int(input("Enter radius"))
area=3.14*r*r
circum=2*3.14*r
print("area",area)
print("circumference",round(circum,2))
OUtput:
======== RESTART: C:\Users\RAINBOW\Videos\1.py ========
Enter radius10
area 314.0
circumference 62.8
Output:
odd={1:"one",3:"three",5:"five",7:"seven",9:"nine"}
print(odd.keys())
print(odd.values())
print(odd.items())
print("length",len(odd))
if 7 in odd:
print("7 present")
else:
print(" 7 is not there")
if 2 in odd:
print("2 is present")
else:
print("2 is absent")
print(odd[9])
del odd[9]
print("after del",odd)
Output:
======== RESTART: C:\Users\RAINBOW\Videos\1.py ========
dict_keys([1, 3, 5, 7, 9])
dict_values(['one', 'three', 'five', 'seven', 'nine'])
dict_items([(1, 'one'), (3, 'three'), (5, 'five'), (7, 'seven'), (9,
'nine')])
length 5
7 present
2 is absent
nine
after del {1: 'one', 3: 'three', 5: 'five', 7: 'seven'}
Output:
Output:
n={"0":"Zero","1":"One","2":"Two","3":"Three","4":"Four","5":"Five","6":"S
ix","7":"Seven","8":"Eight","9":"Nine"}
num=input("Enter any number: ")
for i in num:
print(n[i],end=" ")
Output:
= RESTART: C:/Users/Raibow 6/Desktop/1.py
Enter any number: 123
One Two Three
Exercise Questions and Answers:
Output:
= RESTART: C:/Users/rainb/OneDrive/Documents/Desktop/1.py
Enter the email ids of the students"[email protected]","[email protected]"
email ids ('[email protected]', '[email protected]')
user names ('abc', 'xyz')
domain ('gmail.com', 'yahoo.com')
a={1:10,2:20,4:45,3:12}
b=a.values()
c=sorted(b)
print(c[-1],c[-2])
Output:
= RESTART: C:\Users\vijay\OneDrive\Desktop\3.py
45 20
Output:
============= RESTART: C:\Users\vijay\OneDrive\Desktop\3.py ============
Enter the stringw3resource
w : 1
3 : 1
r : 2
e : 2
s : 1
o : 1
u : 1
c : 1
Output: