Skip to content

Commit be7568a

Browse files
Add files via upload
1 parent 4b67277 commit be7568a

2 files changed

Lines changed: 119 additions & 0 deletions

File tree

Atomic.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Fri Sep 6 00:36:38 2019
4+
5+
@author: Ashay Fernandes
6+
"""
7+
8+
9+
atmdi={ "H":"Hydrogen","O":"Oxygen","C":"carbon","Na":"Sodium","He":"Helium"
10+
11+
}
12+
def AtomicDictionary():
13+
14+
while True:
15+
ki=input("enter the key :")
16+
val= input("enter the value:")
17+
atmdi.update({ki:val})
18+
che=input("enter 0 to finish entering the elements or press enter to continue")
19+
if che=='0':
20+
break
21+
print('The total number of elements in the Dictionary are:',len(atmdi))
22+
23+
while True:
24+
key_value=input("enter the key for which you require value")
25+
print(atmdi.get(key_value))
26+
che=input("enter 0 to finish or press enter to continue")
27+
if che=='0':
28+
break
29+
30+
AtomicDictionary()

assign2.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Thu Sep 5 19:24:13 2019
4+
5+
@author: Ashay Fernandes
6+
"""
7+
8+
""" <q> <1> Create a python class called 'Student' having 'name','age, as attribute along with a
9+
list having the marks obtained for three subjects.
10+
<2> create a constructor to initialize two objects of this class
11+
<3> create a member function called 'display' printing the details of the
12+
specific object.
13+
<4>Ask user to enter the values for an object through an 'accept' member functions
14+
<5>Display these details
15+
"""
16+
class Student:
17+
18+
def __init__(self):
19+
self.lst1=[]
20+
21+
def accept(self):
22+
self.name=input("Enter Student name :")
23+
self.age=input("Enter Student age :")
24+
for i in range(0,3):
25+
self.lst1.append(input("enter marks of Student in three Subjects:"))
26+
27+
def disp(self):
28+
print('Name Of Student :',self.name)
29+
print(' Age Of Student :',self.age)
30+
print('Marks of the Student in subjectis:',self.lst1)
31+
32+
Student1=Student()
33+
Student2=Student()
34+
#
35+
Student1.accept()
36+
Student2.accept()
37+
38+
Student1.disp()
39+
Student2.disp()
40+
41+
""" <q2> Create a dictionary to hold student Details with register numbers as the key
42+
. print those student details whose register numbers are even
43+
"""
44+
studi={"1MS17IS000":["James",19,"O+"],"1MS17IS001":["Jimmy",20,"AB-"],"1MS17IS002":["John",21,"O-"],
45+
"1MS17IS003":["Ellen",18,"AB+"],"1MS17IS004":["Coco",25,"O+"]
46+
47+
}
48+
for i in studi:
49+
val=int((i[7:10]))
50+
if val%2 == 0.0:
51+
print(studi.get(i))
52+
53+
"""<q3> 1> Create a dictionary that contains the atomic element Symbol and the name
54+
2> Add a unique and duplicate element into this dictionary by interacting with the user.
55+
Observe the output and justify
56+
3> Display he numbers of atomic elements in this dictionary
57+
4> Ask the user to enter an element to search in the dictionary. Display
58+
appropriate results
59+
Rewrite this program so that these operations are inside a function called 'AtomicDictionary'.
60+
Create another python file called "Atomic.py" and execute this function in it
61+
"""
62+
63+
atmdi={ "H":"Hydrogen","O":"Oxygen","C":"carbon","Na":"Sodium","He":"Helium"
64+
65+
}
66+
67+
while True:
68+
ki=input("enter the key :")
69+
val= input("enter the value:")
70+
atmdi.update({ki:val})
71+
che=input("enter 0 to finish entering the elements or press enter to continue")
72+
if che=='0':
73+
break
74+
75+
print('The total number of elements in the Dictionary are:',len(atmdi))
76+
77+
key_value=input("enter the key for which you require value")
78+
print(atmdi.get(key_value))
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+

0 commit comments

Comments
 (0)