-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.py
More file actions
591 lines (259 loc) · 10.4 KB
/
functions.py
File metadata and controls
591 lines (259 loc) · 10.4 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# def say_hello():
# print("hello")
# say_hello()
# def print_my_name():
# print("Anna")
# print_my_name()
# def my_fav_country():
# print("USA")
# my_fav_country()
# def my_web_project_and_my_mobile_project():
# print("Shufersal_Online_and_Rami_Levi")
# my_web_project_and_my_mobile_project()
# def say_hello(name):
# print("hello", name)
# say_hello("David")
# def say_hello(name):
# print("hello my name is :", name)
# say_hello("Anna")
# def say_hello(name):
# print("hello my name is :", name)
# say_hello(3)
# def say_hello(patient_id):
# print("patient id is :", patient_id)
# say_hello(306116485)
# def say_goodby(patient_name):
# print("im so sorry ,but we need to say goodby", patient_name)
# say_goodby("Anna")
# def check_patient_id(patient_id):
# print("check_patient_id", patient_id)
# check_patient_id(306116485)
# check_patient_id(306116486)
# check_patient_id(306116487)
# def check_patient_id(patient_id):
# print("check_patient_id", patient_id)
# check_patient_id(306116485, 306116486, 306116487)
# # 1. הגדרת המפעל (הפונקציה)
# def check_patient_ids(patients_list):
# # הלולאה עוברת על הקופסה הגדולה ומוציאה כל פעם תעודת זהות אחת
# for patient_id in patients_list:
# print("check_patient_id", patient_id)
# # 2. הפעלת המפעל ושליחת הנתונים
# check_patient_ids([306116485, 306116486, 306116487])
# def say_goodby(patient_name):
# print("im so sorry ,but we need to say goodby", patient_name)
# say_goodby("Anna")
# say_goodby("Moshe")
# say_goodby("Rachel")
# def say_hello(first_name, last_name, phone_number):
# print("hello", first_name, "your last name", last_name, "and your phone number is", phone_number)
# say_hello("david", "smith", "0502345592")
# def customer_details(first_name, last_name, phone_number):
# print("customer_details: first_name", first_name, "last name:", last_name, "phone_number:", phone_number)
# customer_details("david,", "smith,", "0502345592.")
# def add_two_numbers(a,b):
# print(a+b)
# add_two_numbers(3,4)
# def say_hello(first_name, last_name):
# print("hello", first_name, "your last name", last_name)
# say_hello("Anna", "Rubenchik")
# def minus_number(a,b):
# print(a-b)
# minus_number(4,3)
# def multiply_float(a,b,c):
# print(a*b*c)
# multiply_float(1.1, 2.2, 3.3)
# Write a program that:
# 1. Has a list of student grades:
# student_grades = [95, 70, 82, 60, 48, 100, 73]
# 2. Create a function called check_grade(grade)
# that:
# If grade ≥ 90 → print "Excellent"
# If grade ≥ 70 and < 90 → print "Good"
# If grade ≥ 60 and < 70 → print "Pass"
# Else → print "Fail“
# 3. Use a for loop to go through all grades and
# call the function for each one.
# student_grades = [95, 70, 82, 60, 48, 100, 73]
# check_grade(grade)
# student_grades = [95, 70, 82, 60, 48, 100, 73]
# def check_grade(grade):
# if grade >= 90:
# print("Excellent")
# elif grade >= 70 and grade <= 90:
# print("Good")
# elif grade >= 60 and grade <= 70:
# print ("Pass")
# else:
# print("Fail")
# for i in student_grades:
# check_grade(i)
# def check_grade(grade):
# if grade >= 90:
# print("Excellent")
# elif grade >= 70 and grade < 90:
# print("Good")
# elif grade >= 60 and grade < 70:
# print("Pass")
# else:
# print("Fail")
# def check_grade(grade):
# print("grade", check_grade)
# check_grade ([95, 70, 82, 60, 48, 100, 73])
# def check_grade(grade):
# # הלולאה עוברת על כל ציון בתוך הרשימה
# for student_grade in grade:
# print(f"Grade: {student_grade}")
# # כל התנאים מוזחים פנימה כדי שיתבצעו *בתוך* הלולאה
# # ואנחנו בודקים את המשתנה הבודד 'student_grade'
# if student_grade >= 90:
# print ("Excellent")
# elif student_grade >= 70 and student_grade < 90:
# print ("Good")
# elif student_grade >= 60 and student_grade < 70:
# print ("Pass")
# else:
# print("Fail")
# print("---") # קו מפריד כדי שיהיה נוח לקרוא בטרמינל
# check_grade([95, 70, 82, 60, 48, 100, 73])
# # 1. הגדרת המפעל (הפונקציה)
# def check_patient_ids(patients_list):
# # הלולאה עוברת על הקופסה הגדולה ומוציאה כל פעם תעודת זהות אחת
# for patient_id in patients_list:
# print("check_patient_id", patient_id)
# # 2. הפעלת המפעל ושליחת הנתונים
# check_patient_ids([306116485, 306116486, 306116487])
# # 1. הנתונים שלנו (Test Data)
# student_grades = [95, 70, 82, 60, 48, 100, 73]
# # 2. מכונת הבדיקה שלנו שתדע לבדוק ציון אחד בכל פעם (The Test Case)
# def check_grade(grade):
# if grade >= 90:
# print("Excellent")
# elif grade >= 70 and grade < 90:
# print("Good")
# elif grade >= 60 and grade < 70:
# print("Pass")
# else:
# print("Fail")
# # # 3. מריץ הבדיקות האוטומטי - שולף ציון ושולח למכונה, שולף ציון ושולח למכונה...
# for current_grade in student_grades:
# check_grade(current_grade)
# Check numbers above or below 50
# numbers = [12, 55, 76, 44, 3, 99, 61]
# Create a function that:
# If number > 50 → print "Bigger than 50"
# If number = 50 print "Equal to 50"
# Else → print "Smaller than 50"
# Use a for loop to go through the list and call the function for each number
# numbers = [12, 55, 76, 44, 3, 99, 61]
# def check_number(number):
# if number>50:
# print("Bigger than 50")
# elif number==50:
# print("Equal to 50")
# else:
# print("Smaller than 50")
# for i in numbers:
# check_number(i)
# Four siblings: Sunny, Mary, Katy, and John were arguing about who is the oldest.
# Here’s what they said:
# •Sunny is older than Mary
# •John is younger than Katy
# •Mary is older than John
# •Katy is NOT the oldest
# Your Task
# Use the clues to determine the order from oldest → youngest, put them inside a list in the correct order, and then use a function + for loop to print them.
# # 1. יוצרים את הרשימה לפי הסדר מהמבוגר לצעיר
# siblings = ["Sunny", "Katy", "Mary", "John"]
# # 2. מגדירים פונקציה שמקבלת רשימה
# def show_oldest_to_youngest(names_list):
# # 3. לולאת for שעוברת על כל שם ומדפיסה
# for name in names_list:
# print(name)
# # קוראים לפונקציה (Call) עם הרשימה שלנו
# show_oldest_to_youngest(siblings)
# def get_discount_price(price):
# return price * 0.9 # מחזיר את המחיר אחרי 10% הנחה
# # עכשיו אני יכול לשמור את התוצאה במשתנה ולהשתמש בה בטסט
# final_price = get_discount_price(200)
# if final_price < 250:
# print("Test Passed: Discount applied correctly")
# def open_browser(browser_type="Chrome"): # הגדרנו ברירת מחדל
# print(f"Opening {browser_type} browser...")
# open_browser() # יפתח כרום אוטומטית
# open_browser("Firefox") # יפתח פיירפוקס כי ביקשנו במיוחד
# .1כתבו פונקציה שנקראת print_my_name()
# בתוכה, הכניסו פקודת print שמדפיסה את השם שלכם.
# .2 כתבו פונקציה שתדפיס מדינה בעולם שהייתם רוצים לטוס אליה.
# 3. כתבו פונקציה שתדפיס את השם של אפליקציית ה web –וה- mobile מהפרויקטים שלכם.
# def print_my_name():
# print("My name is Anna")
# print_my_name()
# def my_fav_country():
# print("I loveeeee USA")
# my_fav_country()
# def my_web_and_mobile_projects():
# print("my web and mobile projects are Shufersal and Rami levi")
# my_web_and_mobile_projects()
# def add_first_name_to_last_name(first_name, last_name):
# print(f"Hello {first_name} {last_name}")
# add_first_name_to_last_name("Anna", "Rubenchik")
# def minus_number(a, b):
# print(a-b)
# minus_number(2, 1)
# def multiply_function(a, b, c):
# print(a*b*c)
# multiply_function(1.1, 2.2, 3.3)
# Write a program that:
# 1. Has a list of student grades:
# student_grades = [95, 70, 82, 60, 48, 100, 73]
# 2. Create a function called check_grade(grade)
# that:
# If grade ≥ 90 → print "Excellent"
# If grade ≥ 70 and < 90 → print "Good"
# If grade ≥ 60 and < 70 → print "Pass"
# Else → print "Fail“
# 3. Use a for loop to go through all grades and
# call the function for each one.
# student_grades = [95, 70, 82, 60, 48, 100, 73]
# def check_grade(grade):
# if grade >= 90:
# print("Excellent")
# elif grade >= 70 and grade < 90:
# print("Good")
# elif grade >= 60 and grade < 70:
# print ("Pass")
# else:
# print("Fail")
# for i in student_grades:
# check_grade (i)
# Check numbers above or below 50
# numbers = [12, 55, 76, 44, 3, 99, 61]
# Create a function that:
# If number > 50 → print "Bigger than 50"
# If number = 50 print "Equal to 50"
# Else → print "Smaller than 50"
# Use a for loop to go through the list and call the function for each number
# numbers = [12, 55, 76, 44, 3, 99, 61]
# def above_or_below (number):
# if number > 50:
# print("Bigger than 50")
# elif number == 50:
# print("Equal to 50")
# else:
# print("Smaller than 50")
# for i in numbers:
# above_or_below (i)
# Four siblings: Sunny, Mary, Katy, and John were arguing about who is the oldest.
# Here’s what they said:
# •Sunny is older than Mary
# •John is younger than Katy
# •Mary is older than John
# •Katy is NOT the oldest
# Your Task
# Use the clues to determine the order from oldest → youngest, put them inside a list in the correct order, and then use a function + for loop to print them.
# siblings = ["Sunny", "Katy", "Mary", "John"]
# def from_oldest_to_youngest(sibling):
# print(sibling)
# for i in siblings:
# from_oldest_to_youngest (i)