-
Notifications
You must be signed in to change notification settings - Fork 0
/
studentoop.py
68 lines (45 loc) · 1.43 KB
/
studentoop.py
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
# def main():
##### 1st method
#name = get_name()
# house = get_house()
##### 2nd Method using tuple
# name , house = get_student()
# print(f"{name} from {house}")
#### 3rd method using index
# student = get_student()
# print(f"{student[0]} from {student[1]}")
########### remove the name variable since we are using it once and use return
# def get_name():
# name = input("name: ")
# return name
# def get_name():
# return input("name: ")
# def get_house():
# return input("House: ")
# def get_student():
# name = input("Name: ")
# house = input("House: ")
# return (name, house)
############ Dictionar Object with keys and Values ##########
# def main():
# student = get_student()
# print(f"{student['name']} from {student['house']}")
# def get_student():
# student = {}
# student["name"] = input("Name: ")
# student["house"] = input("House: ")
# return student
# if __name__ == "__main__": ##### if the name of this file equals name then let us go ahead and call main
# main()
######### Make changes in a dictionary #######
def main():
student = get_student()
if student ["name"] == "Sarah":
student["house"] == "Miti Moja"
print (f"{student['name']} from {student['house']}")
def get_student():
name = input("Name: ")
house = input("House: ")
return {"name": name, "house": house}
if __name__ == "__main__":
main()