|
| 1 | +# def greet(): |
| 2 | +# print('Good evening') |
| 3 | +# print('Welcome to Functions') |
| 4 | + |
| 5 | +# greet() |
| 6 | + |
| 7 | + |
| 8 | +# def greet(first_name, last_name): |
| 9 | +# print(f'Hello {first_name}, {last_name}') |
| 10 | + |
| 11 | +# greet('Wayne', 'Bruce') |
| 12 | +# greet('Grey', 'Jean') |
| 13 | +# greet('Jean', 'Grey') |
| 14 | + |
| 15 | + |
| 16 | +# 2 function types --> Values and Task |
| 17 | +#Task |
| 18 | +# def greet(name): |
| 19 | +# print(f'{name}, from print function') |
| 20 | +# return name #value from function |
| 21 | + |
| 22 | +# print(greet('Joe')) |
| 23 | + |
| 24 | + |
| 25 | +#Value |
| 26 | +# def get_greeting(name): |
| 27 | +# return f'Good evening {name}' |
| 28 | +# message = get_greeting('Paul') |
| 29 | +# file = open('get_greeting.txt', 'w') |
| 30 | +# file.write(message) |
| 31 | +# file.close() |
| 32 | + |
| 33 | + |
| 34 | +# #flush this out.. |
| 35 | +# def get_greeting2(): |
| 36 | +# results = get_greeting() |
| 37 | +# return results |
| 38 | + |
| 39 | +# print(get_greeting2('Larry')) |
| 40 | + |
| 41 | + |
| 42 | +# def increment(number, by): |
| 43 | +# return number + by |
| 44 | + |
| 45 | +# result = increment(3, 1) |
| 46 | +# print(result) |
| 47 | + |
| 48 | + |
| 49 | +# def increment(number, by=1): |
| 50 | +# return number + by |
| 51 | +# print(increment(2)) |
| 52 | + |
| 53 | + |
| 54 | +# def increment(number, by=1): |
| 55 | +# return number + by |
| 56 | +# print(increment(2, 13)) |
| 57 | + |
| 58 | +# def increment(num1=1, num2=1): |
| 59 | +# return num2 +num1 |
| 60 | +# print(increment(num2=5, num1=13)) |
| 61 | + |
| 62 | + |
| 63 | +#this will result in Typeerror |
| 64 | +# def multiply(a, b): |
| 65 | +# return a*b |
| 66 | + |
| 67 | +# print(multiply(2, 4, 6, 8)) |
| 68 | + |
| 69 | +#xargs |
| 70 | +# def multiply(*nums): #[2, 4, 6, 8] |
| 71 | +# total = 1 |
| 72 | +# for n in nums: |
| 73 | +# #print(n) |
| 74 | +# #total = total * n |
| 75 | +# total *=n |
| 76 | +# return total |
| 77 | + |
| 78 | +# print(multiply(2, 4, 6, 8)) |
| 79 | + |
| 80 | +#xxargs --> key/word |
| 81 | +# def user_demographics(**user): |
| 82 | +# print(user['name'], user['confirmed']) |
| 83 | + |
| 84 | +# user_demographics(id=100, name='Parker', age=35, confirmed ='N') |
| 85 | + |
| 86 | +# def patient(): |
| 87 | +# MRN = '7VLYZ' |
| 88 | + |
| 89 | +#print(MRN) #not accessible to local scope |
| 90 | + |
| 91 | +# MRN = 'Z10111' |
| 92 | +# def patient(name): |
| 93 | +# MRN = '85RZLL' |
| 94 | + |
| 95 | +# def doctor(name): |
| 96 | +# MRN = '67382C' |
| 97 | + |
| 98 | +# patient('Smith') |
| 99 | +# print(MRN) |
| 100 | + |
| 101 | +# def repeat(quote, num): |
| 102 | +# print(quote * num) |
| 103 | + |
| 104 | +# print(repeat('Live your best life ', 5)' |
| 105 | + |
| 106 | +# def get_temp(temp): |
| 107 | +# if temp > 90: |
| 108 | +# return 'Hot' |
| 109 | +# elif temp >75 and temp <=90: |
| 110 | +# return 'Warm' |
| 111 | +# elif 60 <temp <=75: |
| 112 | +# return 'Comfortable' |
| 113 | +# elif 45 <temp <=60: |
| 114 | +# return 'Chilly' |
| 115 | +# else: |
| 116 | +# return 'Pack your parka' |
| 117 | + |
| 118 | + |
| 119 | +# print(get_temp(40)) |
| 120 | + |
| 121 | + |
0 commit comments