· 6 years ago · Dec 07, 2019, 05:48 PM
1
2import Images
3
4class Profile():
5 def __init__(self, id,fname, lname, age, email, hobby):
6 self.id=id
7 self.fname= fname
8 self.lname=lname
9 self.age= age
10 self.email= email
11 self.hobby= hobby
12
13
14-----------------------------------------------------------------------
15
16
17
18
19from FUN_SS.FUN import Profile
20from PIL import Image
21import random
22import smtplib
23from email.message import EmailMessage
24
25
26def main():
27 id= 0
28 lis=[]
29 swtich = True
30 print("Welcome to my program !")
31 print("--------------------------------------------")
32 while(swtich):
33 print("Enter one of the following options: ")
34 print("1. Add profile")
35 print("2. Display profile")
36 print("3. Search for a profile")
37 print("4. Remove profile")
38 print("5. Remove All")
39 print("6. Pictures")
40 print("7. Resize pictures")
41 print("8. Random number game")
42 print("9. Sending Email for all profiles")
43 print("10. Exit")
44 option= int(input("Your options: "))
45
46 if (option == 1): # add into the list
47 id= id+1
48 lis.append(Profile(id, str(input("Enter your first name: ")),str(input("Enter your last name: ")),
49 int(input("Enter your age: ")), str(input("Enter your email without writing @gmail.com: "))+"@gmail.com", str(input("Enter your hobby: "))))
50
51
52 elif(option==2): # print the list
53 for obj in lis:
54 print("--------------------------------------------")
55 print(f"ID: {obj.id}")
56 print(f"First Name: {obj.fname}")
57 print(f"Last Name: {obj.lname}")
58 print(f"Age: {obj.age}")
59 print(f"Email: {obj.email}")
60 print(f"Hobby: {obj.hobby}")
61 print("--------------------------------------------")
62 elif(option == 3): # search for an object in the list
63 enter=int(input("Enter the ID you want to display: "))
64 for obj in lis:
65
66 if(enter==obj.id):
67 print("--------------------------------------------")
68 print(f"ID: {obj.id}")
69 print(f"First Name: {obj.fname}")
70 print(f"Last Name: {obj.lname}")
71 print(f"Age: {obj.age}")
72 print(f"Email: {obj.email}")
73 print(f"Hobby: {obj.hobby}")
74 print("--------------------------------------------")
75 elif(option==4): # remove an object from the list
76 enter= int(input("Enter the ID you want to delete the list: "))
77 for obj in lis:
78 if (enter==obj.id):
79 lis.remove(obj)
80
81 elif(option==5): # clear the list
82 lis.clear()
83
84 elif (option == 6): # image opening
85 print("Enter one of the following Images you want to display: ")
86 print("1. Irelia")
87 print("2. Irelia Mirror")
88 print("3. IG Irelia")
89 print("4. Exit")
90 option2 = int(input("Your option: "))
91 if(option2 == 1):
92 ima = Image.open('Screen Shot 1441-03-13 at 3.10.09 PM copy.png')
93 ima.show()
94
95 elif(option2 == 2):
96 ima2 = Image.open('157338784156073568 copy.png')
97 ima2.show()
98
99 elif(option2 == 3):
100 ima3 = Image.open('Screen Shot 1441-01-28 at 3.03.54 PM copy.png')
101 ima3.show()
102
103 elif(option2 == 4):
104 continue
105
106 else:
107 print("You have entered wrong number please try again")
108
109
110 elif (option == 7): # image resizing with thumbnailing
111 print("Enter one of the following Images you want to display: ")
112 print("1. Resize Irelia")
113 print("2. Resize Irelia Mirror")
114 print("3. Resize IG Irelia")
115 print("4. Exit")
116 option3 = int(input("Your option: "))
117
118 if (option3 == 1):
119 imag = Image.open('Screen Shot 1441-03-13 at 3.10.09 PM copy.png')
120 he = int(input("Enter height: "))
121 wi = int(input("Enter Width: "))
122 imag.thumbnail((he, wi))
123 imag.save(str(input("Enter the file name you want to save: " )) + ".png")
124 imag.show()
125
126 elif (option3 == 2):
127 imag2 = Image.open('157338784156073568 copy.png')
128 he2 = int(input("Enter height: "))
129 wi2 = int(input("Enter Width: "))
130 imag2.thumbnail((he2, wi2))
131 imag2.save(str(input("Enter the file name you want to save: " )) + ".png")
132 imag2.show()
133 elif (option3 == 3):
134 imag3 = Image.open('Screen Shot 1441-01-28 at 3.03.54 PM copy.png')
135 he3 = int(input("Enter height: "))
136 wi3 = int(input("Enter Width: "))
137 imag3.thumbnail((he3, wi3))
138 imag3.save(str(input("Enter the file name you want to save: " )) + ".png")
139 imag3.show()
140 elif (option3 == 4):
141 continue
142 else:
143 print("You have entered wrong number please try again")
144
145 elif (option == 8): # random game
146 counter= 1
147 switch2=True
148 print("Welcome to the random number game !")
149 print("Guess the number to win the game !")
150 print("If you want to leave the game press 0\n")
151 print("Enter the following options: ")
152 print("1. 1-10")
153 print("2. 1-50")
154 print("3. 1-100")
155 option4 = int(input("Your option: "))
156 if(option4 == 1):
157
158
159 while(switch2): # 1 - 10 game
160 random_number = int(random.randint(1, 10))
161
162 enter=int(input(("Enter numbers from 1-10: ")))
163 print("")
164 if(enter == random_number):
165 print(f"WOOO You won it with record {counter} times\n")
166 switch2= False
167 elif(enter == 0):
168 switch2 = False
169 print("Thank you for playing this game !")
170 else:
171 print("Wrong >.< Try again !\n")
172
173 counter = counter +1
174
175
176 elif (option4 == 2): # 1 - 50 game
177
178 while (switch2):
179 random_number = int(random.randint(1, 50))
180
181 enter2 = int(input(("Enter numbers from 1-50: ")))
182 print("")
183 if (enter2 == random_number):
184 print(f"WOOO You won it with record {counter} times\n")
185 switch2 = False
186 elif (enter2 == 0):
187 switch2 = False
188 print("Thank you for playing this game !")
189 else:
190 print("Wrong >.< Try again !\n")
191
192 counter = counter + 1
193
194
195 elif (option4 == 3): # 1 - 100 game
196
197 while (switch2):
198 random_number = int(random.randint(1, 100))
199
200 enter3 = int(input(("Enter numbers from 1-50: ")))
201 print("")
202 if (enter3 == random_number):
203 print(f"WOOO You won it with record {counter} times\n")
204 switch2 = False
205 elif (enter3 == 0):
206 switch2 = False
207 print("Thank you for playing this game !")
208 else:
209 print("Wrong >.< Try again !\n")
210
211 counter = counter + 1
212
213
214
215 elif (option == 9): # email
216
217
218
219 email = EmailMessage()
220 email['from'] = str(input(("From: ")))
221 for i in lis:
222 email['to'] = i.email
223 email['subject']= str(input("Subject: "))
224 email.set_content(str(input("Message: ")))
225 with smtplib.SMTP(host= 'smtp.gmail.com', port = 587) as smtp:
226 smtp.ehlo() #connection
227 smtp.starttls()# start security
228 smtp.login(str(input("Email: ")), str(input("Password: ")))
229 smtp.send_message(email)
230
231 print("MESSAGE SENT !")
232
233
234 elif (option==10): # Exit
235 swtich=False
236
237 else:
238 print("You have entered wrong number please try again\n")
239
240 # main run
241if __name__=='__main__':
242 main()