├── .idea ├── .gitignore ├── 100DaysOfPython.iml ├── inspectionProfiles │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── Day_1 ├── ex_1_printing.py ├── ex_2_debugging.py ├── ex_3_input.py ├── ex_4_swapping_numbers.py ├── hello_world.py ├── input_function.py ├── project_band_name_generator.py └── variables.py ├── Day_2 ├── ex_1.py ├── f_strings.py ├── maths_operations.py ├── primitive_data_types.py ├── project_tip_calculator.py └── type_conversion.py ├── Day_3 ├── ex_1.py ├── ex_2.py ├── ex_3.py ├── ex_4.py ├── ex_5.py ├── if_elif_else.py ├── if_else.py ├── if_succession.py ├── logical_operator.py ├── nested_if.py └── project_treasure_island.py ├── Day_4 ├── ex_1.py ├── ex_2.py ├── lists.py ├── nested_lists.py ├── project_rock_paper_scissors.py └── random_module.py ├── Day_5 ├── ex_1.py ├── ex_2.py ├── ex_3.py ├── ex_4.py ├── for_loop.py ├── for_loop_range.py ├── project_password_generator.py └── sum_of_first_100_numbers.py └── Day_6 ├── fun_eg.py ├── function_example_1.py ├── function_example_2.py ├── function_example_3.py ├── function_example_4.py ├── function_example_5.py ├── lambda_functions.py ├── practice_pattern.py ├── recursion_counter.py └── recursion_factorial_function.py /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/100DaysOfPython.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Day_1/ex_1_printing.py: -------------------------------------------------------------------------------- 1 | #Write your code below this line 👇 2 | print("""Day 1 - Python Print Function 3 | The function is declared like this: 4 | print('what to print')""") -------------------------------------------------------------------------------- /Day_1/ex_2_debugging.py: -------------------------------------------------------------------------------- 1 | print("Day 1 - String Manipulation") 2 | print('String Concatenation is done with the "+" sign.') 3 | print('e.g. print("Hello " + "world")') 4 | print("New lines can be created with a backslash and n.") 5 | -------------------------------------------------------------------------------- /Day_1/ex_3_input.py: -------------------------------------------------------------------------------- 1 | #Write your code below this line 👇 2 | print(len(input("What is your name?"))) -------------------------------------------------------------------------------- /Day_1/ex_4_swapping_numbers.py: -------------------------------------------------------------------------------- 1 | #Don't change the code below 2 | a = input("a: ") 3 | b = input("b: ") 4 | # 🚨 Don't change the code above 5 | #################################### 6 | #Write your code below this line 7 | 8 | temp = a 9 | a = b 10 | b = temp 11 | 12 | #Write your code above this line 13 | #################################### 14 | #Don't change the code below 15 | print("a: " + a) 16 | print("b: " + b) -------------------------------------------------------------------------------- /Day_1/hello_world.py: -------------------------------------------------------------------------------- 1 | print("hello world!") -------------------------------------------------------------------------------- /Day_1/input_function.py: -------------------------------------------------------------------------------- 1 | print("hello " + input("enter your name:") + "!") -------------------------------------------------------------------------------- /Day_1/project_band_name_generator.py: -------------------------------------------------------------------------------- 1 | print("welcome to the band name generator!") 2 | city_name = input("What's name of the city tu grew up in?\n") 3 | pet_name = input("What's your pet's name?\n") 4 | print("your band name could be " + city_name + " " + pet_name) -------------------------------------------------------------------------------- /Day_1/variables.py: -------------------------------------------------------------------------------- 1 | #strings 2 | name = "yash" 3 | print(name) 4 | print(type(name)) 5 | 6 | #integer 7 | age = 21 8 | age += 1 9 | print(age) 10 | 11 | #float 12 | height = 176.5 13 | print(height) 14 | 15 | #boolean 16 | human = True 17 | print(human) -------------------------------------------------------------------------------- /Day_2/ex_1.py: -------------------------------------------------------------------------------- 1 | # Don't change the code below 2 | two_digit_number = input("Type a two digit number: ") 3 | # Don't change the code above 4 | add = int(two_digit_number[0])+int(two_digit_number[1]) 5 | print(add) 6 | #################################### 7 | #Write your code below this line -------------------------------------------------------------------------------- /Day_2/f_strings.py: -------------------------------------------------------------------------------- 1 | height = 1.8 2 | score = 400 3 | isWinning = True 4 | print(f"your height is {height},your score is {score},you are winning is {isWinning}") -------------------------------------------------------------------------------- /Day_2/maths_operations.py: -------------------------------------------------------------------------------- 1 | #1 + 2 addition 2 | #1 - 2 subtraction 3 | #1 / 2 division 4 | #1 * 2 multiplication 5 | #1 ** 2 exponent 6 | -------------------------------------------------------------------------------- /Day_2/primitive_data_types.py: -------------------------------------------------------------------------------- 1 | #data types 2 | 3 | #string 4 | "hello"[4] 5 | print("123"+"345") 6 | 7 | #integer 8 | print(123+456) 9 | 10 | #float 11 | pi = 3.14159 12 | 13 | #boolean 14 | 15 | True 16 | False -------------------------------------------------------------------------------- /Day_2/project_tip_calculator.py: -------------------------------------------------------------------------------- 1 | print("welcome to the tip calculator") 2 | bill = float(input("what was the total bill? $")) 3 | tip = int(input("what percentage tip would you like to give? 10,12 or 15? ")) 4 | people = int(input("how many people to split the bill? ")) 5 | bill_with_tip = tip * 100 / bill + bill 6 | bill_per_person = bill_with_tip / people 7 | final_bill = round(bill_per_person,2) 8 | print(f"each person should pay ${final_bill}") -------------------------------------------------------------------------------- /Day_2/type_conversion.py: -------------------------------------------------------------------------------- 1 | num_char = len(input("enter your name:")) 2 | new_num_char = str(num_char) 3 | print("your name has "+ new_num_char + " characters") 4 | 5 | a = float(123) 6 | print(type(a)) 7 | 8 | print(70+float("100.50")) 9 | print(str(70) + str(100)) -------------------------------------------------------------------------------- /Day_3/ex_1.py: -------------------------------------------------------------------------------- 1 | # Don't change the code below 2 | number = int(input("Which number do you want to check? ")) 3 | # Don't change the code above 4 | 5 | #Write your code below this line 6 | if number%2 == 0: 7 | print("This is an even number.") 8 | else: 9 | print("This is an odd number.") -------------------------------------------------------------------------------- /Day_3/ex_2.py: -------------------------------------------------------------------------------- 1 | # 🚨 Don't change the code below 👇 2 | height = float(input("enter your height in m: ")) 3 | weight = float(input("enter your weight in kg: ")) 4 | # 🚨 Don't change the code above 👆 5 | 6 | #Write your code below this line 👇 7 | bmi = round(weight / height ** 2) 8 | if bmi < 18.5: 9 | print(f"Your BMI is {bmi}, you are underweight.") 10 | elif bmi <= 25: 11 | print(f"Your BMI is {bmi}, you have a normal weight.") 12 | elif bmi <= 30: 13 | print(f"Your BMI is {bmi}, you are slightly overweight.") 14 | elif bmi <= 35: 15 | print(f"Your BMI is {bmi}, you are obese.") 16 | else: 17 | print(f"Your BMI is {bmi}, you are clinically obese.") -------------------------------------------------------------------------------- /Day_3/ex_3.py: -------------------------------------------------------------------------------- 1 | # 🚨 Don't change the code below 👇 2 | year = int(input("Which year do you want to check? ")) 3 | # 🚨 Don't change the code above 👆 4 | 5 | #Write your code below this line 👇 6 | if year%4 == 0: 7 | if year%100== 0: 8 | if year%400 == 0: 9 | print("leap year") 10 | else: 11 | print("not a leap year") 12 | else: 13 | print("leap year") 14 | else: 15 | print("not a leap year") 16 | 17 | 18 | -------------------------------------------------------------------------------- /Day_3/ex_4.py: -------------------------------------------------------------------------------- 1 | # 🚨 Don't change the code below 👇 2 | print("Welcome to Python Pizza Deliveries!") 3 | size = input("What size pizza do you want? S, M, or L ") 4 | add_pepperoni = input("Do you want pepperoni? Y or N ") 5 | extra_cheese = input("Do you want extra cheese? Y or N ") 6 | # 🚨 Don't change the code above 👆 7 | 8 | #Write your code below this line 👇 9 | bill = 0 10 | if size == "S": 11 | bill = 15 12 | elif size == "M": 13 | bill = 20 14 | elif size == "L": 15 | bill = 25 16 | if add_pepperoni == "Y": 17 | if size == "S": 18 | bill += 2 19 | else: 20 | bill += 3 21 | if extra_cheese == "Y": 22 | bill += 1 23 | print(f"Your final bill is: ${bill}.") -------------------------------------------------------------------------------- /Day_3/ex_5.py: -------------------------------------------------------------------------------- 1 | # 🚨 Don't change the code below 👇 2 | print("Welcome to the Love Calculator!") 3 | name1 = input("What is your name? \n") 4 | name2 = input("What is their name? \n") 5 | # 🚨 Don't change the code above 👆 6 | 7 | #Write your code below this line 👇 8 | comb_name = name1 + name2 9 | comb_name.lower() 10 | 11 | t = comb_name.count('t') 12 | r = comb_name.count('r') 13 | u = comb_name.count('u') 14 | e = comb_name.count('e') 15 | 16 | true = t + r + u + e 17 | 18 | l = comb_name.count('l') 19 | o = comb_name.count('o') 20 | v = comb_name.count('v') 21 | e = comb_name.count('e') 22 | 23 | love = l + o + v + e 24 | 25 | love_score = str(true) + str(love) 26 | score = int(love_score) 27 | if (score < 10) or (score > 90): 28 | print(f"Your score is {score}, you go together like coke and mentos.") 29 | elif (score > 40) and (score < 50): 30 | print(f"Your score is {score}, you are alright together.") 31 | else: 32 | print(f"Your score is {score}.") 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Day_3/if_elif_else.py: -------------------------------------------------------------------------------- 1 | print("welcome to the rollercoaster") 2 | height = int(input("what is your height in cm?:")) 3 | if height > 120: 4 | print("you can ride the rollercoaster") 5 | age = int(input("what is your age? ")) 6 | if age < 12: 7 | print("please pay 5$") 8 | elif age <= 18: 9 | print("please pay 7$") 10 | else: 11 | print("please pay 12$") 12 | else: 13 | print("you have to grow taller before you ride!") -------------------------------------------------------------------------------- /Day_3/if_else.py: -------------------------------------------------------------------------------- 1 | print("welcome to the rollercoaster") 2 | height = int(input("what is your height in cm?:")) 3 | if height > 120: 4 | print("you can ride the rollercoaster") 5 | else: 6 | print("you have to grow taller before you ride!") -------------------------------------------------------------------------------- /Day_3/if_succession.py: -------------------------------------------------------------------------------- 1 | print("welcome to the rollercoaster") 2 | height = int(input("what is your height in cm?:")) 3 | bill = 0 4 | if height > 120: 5 | age = int(input("what is your age? ")) 6 | if age < 12: 7 | bill = 5 8 | print("child tickets are 5$") 9 | elif age <= 18: 10 | bill = 7 11 | print("youth tickets are 7$") 12 | else: 13 | bill = 12 14 | print("adult tickets are 12$") 15 | wants_photo = input("do you want a photo taken? Y or N. ") 16 | if wants_photo == "Y": 17 | bill += 3 18 | print("you can ride the rollercoaster") 19 | print(f"your final bill is {bill}") 20 | else: 21 | print("you have to grow taller before you ride!") -------------------------------------------------------------------------------- /Day_3/logical_operator.py: -------------------------------------------------------------------------------- 1 | print("welcome to the rollercoaster") 2 | height = int(input("what is your height in cm?:")) 3 | bill = 0 4 | if height > 120: 5 | age = int(input("what is your age? ")) 6 | if age < 12: 7 | bill = 5 8 | print("child tickets are 5$") 9 | elif age <= 18: 10 | bill = 7 11 | print("youth tickets are 7$") 12 | elif age >=45 and age <=55: 13 | print("you can have a free ticket") 14 | else: 15 | bill = 12 16 | print("adult tickets are 12$") 17 | wants_photo = input("do you want a photo taken? Y or N. ") 18 | if wants_photo == "Y": 19 | bill += 3 20 | print("you can ride the rollercoaster") 21 | print(f"your final bill is {bill}") 22 | else: 23 | print("you have to grow taller before you ride!") -------------------------------------------------------------------------------- /Day_3/nested_if.py: -------------------------------------------------------------------------------- 1 | print("welcome to the rollercoaster") 2 | height = int(input("what is your height in cm?:")) 3 | if height > 120: 4 | print("you can ride the rollercoaster") 5 | age = int(input("what is your age? ")) 6 | if age <= 18: 7 | print("please pay 7$") 8 | else: 9 | print("please pay 12$") 10 | else: 11 | print("you have to grow taller before you ride!") -------------------------------------------------------------------------------- /Day_3/project_treasure_island.py: -------------------------------------------------------------------------------- 1 | print(''''******************************************************************************* 2 | | | | | 3 | _________|________________.=""_;=.______________|_____________________|_______ 4 | | | ,-"_,="" `"=.| | 5 | |___________________|__"=._o`"-._ `"=.______________|___________________ 6 | | `"=._o`"=._ _`"=._ | 7 | _________|_____________________:=._o "=._."_.-="'"=.__________________|_______ 8 | | | __.--" , ; `"=._o." ,-"""-._ ". | 9 | |___________________|_._" ,. .` ` `` , `"-._"-._ ". '__|___________________ 10 | | |o`"=._` , "` `; .". , "-._"-._; ; | 11 | _________|___________| ;`-.o`"=._; ." ` '`."\` . "-._ /_______________|_______ 12 | | | |o; `"-.o`"=._`` '` " ,__.--o; | 13 | |___________________|_| ; (#) `-.o `"=.`_.--"_o.-; ;___|___________________ 14 | ____/______/______/___|o;._ " `".o|o_.--" ;o;____/______/______/____ 15 | /______/______/______/_"=._o--._ ; | ; ; ;/______/______/______/_ 16 | ____/______/______/______/__"=._o--._ ;o|o; _._;o;____/______/______/____ 17 | /______/______/______/______/____"=._o._; | ;_.--"o.--"_/______/______/______/_ 18 | ____/______/______/______/______/_____"=.o|o_.--""___/______/______/______/____ 19 | /______/______/______/______/______/______/______/______/______/______/[TomekK] 20 | *******************************************************************************''') 21 | print("Welcome to treasure island") 22 | print("Your mission is to find the treasure") 23 | 24 | left_or_right = input("you're at a cross road.where do you want to go? type "'"left" or "right"\n') 25 | if left_or_right == "left" or left_or_right == "LEFT": 26 | swim_or_wait = input("you come to a lake. there is and island in the middle of the lake. type "'"wait" to wait for a boat.type swim to "swim" across.\n') 27 | 28 | if swim_or_wait == "wait" or swim_or_wait == "wait": 29 | door = input("you arrive at the island unharmed. there is a house with 3 doors. One,red one yellow and one blue. Which colour do you choose?\n") 30 | 31 | if door == "yellow" or door == "YELLOW": 32 | print("you win!") 33 | elif door == "red" or door == "RED": 34 | print("Burned by fire Game Over") 35 | elif door == "blue" or door == "BLUE": 36 | print("eaten by beasts Game Over") 37 | else: 38 | print("Game Over") 39 | 40 | else: 41 | print("attacked by trout Game Over") 42 | 43 | else: 44 | print("fall into hole Game Over") -------------------------------------------------------------------------------- /Day_4/ex_1.py: -------------------------------------------------------------------------------- 1 | # Remember to use the random module 2 | # Hint: Remember to import the random module here at the top of the file. 🎲 3 | import random 4 | 5 | # 🚨 Don't change the code below 👇 6 | test_seed = int(input("Create a seed number: ")) 7 | random.seed(test_seed) 8 | # 🚨 Don't change the code above 👆 It's only for testing your code. 9 | 10 | # Write the rest of your code below this line 👇 11 | coin = random.randint(0, 1) 12 | if coin == 1: 13 | print("Heads") 14 | elif coin == 0: 15 | print("Tails") -------------------------------------------------------------------------------- /Day_4/ex_2.py: -------------------------------------------------------------------------------- 1 | import random 2 | # 🚨 Don't change the code below 👇 3 | test_seed = int(input("Create a seed number: ")) 4 | random.seed(test_seed) 5 | 6 | # Split string method 7 | names_string = input("Give me everybody's names, separated by a comma. ") 8 | names = names_string.split(", ") 9 | # 🚨 Don't change the code above 👆 10 | 11 | #Write your code below this line 👇 12 | num = len(names) 13 | bill = random.randint(0,num - 1) 14 | person_who_will_pay = names[bill] 15 | print(person_who_will_pay + " is going to buy the meal today!") -------------------------------------------------------------------------------- /Day_4/lists.py: -------------------------------------------------------------------------------- 1 | states_of_america = ["delaware","pennysylvania","new jersey","georgia","ohio"] 2 | print(states_of_america[0]) 3 | states_of_america[1] = "pencilvania" 4 | print(states_of_america[1]) 5 | print(states_of_america[-1]) 6 | states_of_america.append("california") 7 | print(states_of_america) -------------------------------------------------------------------------------- /Day_4/nested_lists.py: -------------------------------------------------------------------------------- 1 | fruits = ["strawberries","nectarines","apples","grapes"] 2 | vegetables = ["spinach","kale","tomatoes","celery","potatoes"] 3 | dirty_dozen = [fruits,vegetables] 4 | print(dirty_dozen) -------------------------------------------------------------------------------- /Day_4/project_rock_paper_scissors.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | rock = ''' 4 | _______ 5 | ---' ____) 6 | (_____) 7 | (_____) 8 | (____) 9 | ---.__(___) 10 | ''' 11 | 12 | paper = ''' 13 | _______ 14 | ---' ____)____ 15 | ______) 16 | _______) 17 | _______) 18 | ---.__________) 19 | ''' 20 | 21 | scissors = ''' 22 | _______ 23 | ---' ____)____ 24 | ______) 25 | __________) 26 | (____) 27 | ---.__(___) 28 | ''' 29 | 30 | game_images = [rock, paper, scissors] 31 | 32 | user_choice = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n")) 33 | print(game_images[user_choice]) 34 | 35 | computer_choice = random.randint(0, 2) 36 | print("Computer chose:") 37 | print(game_images[computer_choice]) 38 | 39 | if user_choice >= 3 or user_choice < 0: 40 | print("You typed an invalid number, you lose!") 41 | elif user_choice == 0 and computer_choice == 2: 42 | print("You win!") 43 | elif computer_choice == 0 and user_choice == 2: 44 | print("You lose") 45 | elif computer_choice > user_choice: 46 | print("You lose") 47 | elif user_choice > computer_choice: 48 | print("You win!") 49 | elif computer_choice == user_choice: 50 | print("It's a draw") -------------------------------------------------------------------------------- /Day_4/random_module.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | random_integer = random.randint(1,10) 4 | print(random_integer) 5 | 6 | random_float = random.random() * 5 7 | print(random_float) 8 | 9 | love_score = random.randint(1,100) 10 | print(f"your love score is {love_score}") -------------------------------------------------------------------------------- /Day_5/ex_1.py: -------------------------------------------------------------------------------- 1 | # 🚨 Don't change the code below 👇 2 | student_heights = input("Input a list of student heights ").split() 3 | for n in range(0, len(student_heights)): 4 | student_heights[n] = int(student_heights[n]) 5 | # 🚨 Don't change the code above 👆 6 | 7 | 8 | #Write your code below this row 👇 9 | total_students = 0 10 | for no_of_student in student_heights: 11 | total_students += 1 12 | sum_of_heights = 0 13 | for total_height in student_heights: 14 | sum_of_heights += total_height 15 | 16 | avg = round(sum_of_heights / total_students) 17 | print(avg) 18 | 19 | 20 | -------------------------------------------------------------------------------- /Day_5/ex_2.py: -------------------------------------------------------------------------------- 1 | # 🚨 Don't change the code below 👇 2 | student_scores = input("Input a list of student scores ").split() 3 | for n in range(0, len(student_scores)): 4 | student_scores[n] = int(student_scores[n]) 5 | print(student_scores) 6 | # 🚨 Don't change the code above 👆 7 | 8 | #Write your code below this row 👇 9 | highest_score = 0 10 | for score in student_scores: 11 | if score > highest_score: 12 | highest_score = score 13 | print(f"The highest score in the class is: {highest_score}") 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Day_5/ex_3.py: -------------------------------------------------------------------------------- 1 | #Write your code below this row 👇 2 | sum = 0 3 | for i in range(1,101): 4 | if i%2 == 0: 5 | sum += i 6 | print(sum) -------------------------------------------------------------------------------- /Day_5/ex_4.py: -------------------------------------------------------------------------------- 1 | #Write your code below this row 👇 2 | for i in range(1,100): 3 | if (i%3 == 0) and (i%5 == 0): 4 | print("FizzBuzz") 5 | elif (i%3 == 0): 6 | print("Fizz") 7 | elif (i%5 == 0): 8 | print("Buzz") 9 | else: 10 | print(i) 11 | -------------------------------------------------------------------------------- /Day_5/for_loop.py: -------------------------------------------------------------------------------- 1 | fruits = ["apple","peach","pear"] 2 | for fruit in fruits: 3 | print(fruit) 4 | print(fruit + " pie") 5 | print(fruits) -------------------------------------------------------------------------------- /Day_5/for_loop_range.py: -------------------------------------------------------------------------------- 1 | for i in range(1,11,3): 2 | print(i) -------------------------------------------------------------------------------- /Day_5/project_password_generator.py: -------------------------------------------------------------------------------- 1 | #Password Generator Project 2 | import random 3 | letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] 4 | numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] 5 | symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+'] 6 | 7 | print("Welcome to the PyPassword Generator!") 8 | nr_letters = int(input("How many letters would you like in your password?\n")) 9 | nr_symbols = int(input(f"How many symbols would you like?\n")) 10 | nr_numbers = int(input(f"How many numbers would you like?\n")) 11 | 12 | #Eazy Level 13 | # password = "" 14 | 15 | # for char in range(1, nr_letters + 1): 16 | # password += random.choice(letters) 17 | 18 | # for char in range(1, nr_symbols + 1): 19 | # password += random.choice(symbols) 20 | 21 | # for char in range(1, nr_numbers + 1): 22 | # password += random.choice(numbers) 23 | 24 | # print(password) 25 | 26 | #Hard Level 27 | password_list = [] 28 | 29 | for char in range(1, nr_letters + 1): 30 | password_list.append(random.choice(letters)) 31 | 32 | for char in range(1, nr_symbols + 1): 33 | password_list += random.choice(symbols) 34 | 35 | for char in range(1, nr_numbers + 1): 36 | password_list += random.choice(numbers) 37 | 38 | print(password_list) 39 | random.shuffle(password_list) 40 | print(password_list) 41 | 42 | password = "" 43 | for char in password_list: 44 | password += char 45 | 46 | print(f"Your password is: {password}") -------------------------------------------------------------------------------- /Day_5/sum_of_first_100_numbers.py: -------------------------------------------------------------------------------- 1 | sum = 0 2 | for i in range(1,101): 3 | sum += i 4 | print(sum) -------------------------------------------------------------------------------- /Day_6/fun_eg.py: -------------------------------------------------------------------------------- 1 | def cube(n): 2 | return n**3 3 | print(cube(3)) -------------------------------------------------------------------------------- /Day_6/function_example_1.py: -------------------------------------------------------------------------------- 1 | def my_fun(): 2 | """this is a docstring""" 3 | print("hello welcome to python") 4 | my_fun() -------------------------------------------------------------------------------- /Day_6/function_example_2.py: -------------------------------------------------------------------------------- 1 | def square(n): 2 | square = n ** 2 3 | print("square of number is",square) 4 | n = int(input("enter a number to find it's square:")) 5 | square(n) -------------------------------------------------------------------------------- /Day_6/function_example_3.py: -------------------------------------------------------------------------------- 1 | def square(side): 2 | area = side ** 2 3 | peri = 4 * side 4 | print("area of square is ",area) 5 | print("perimeter of square is",peri) 6 | side = int(input("enter value of side:")) 7 | square(side) -------------------------------------------------------------------------------- /Day_6/function_example_4.py: -------------------------------------------------------------------------------- 1 | def circle(r): 2 | area = 3.14 * r ** 2 3 | print("area of circle is",area) 4 | rad = int(input("enter radius of circle:")) 5 | circle(rad) -------------------------------------------------------------------------------- /Day_6/function_example_5.py: -------------------------------------------------------------------------------- 1 | # Program to print the fibonacci series upto n_terms 2 | # Recursive function 3 | 4 | def recursive_fibonacci(n): 5 | if n <= 1: 6 | return n 7 | else: 8 | return (recursive_fibonacci(n - 1) + recursive_fibonacci(n - 2)) 9 | 10 | 11 | n_terms = 10 12 | 13 | # check if the number of terms is valid 14 | if n_terms <= 0: 15 | print("Invalid input ! Please input a positive value") 16 | else: 17 | print("Fibonacci series:") 18 | for i in range(n_terms): 19 | print(recursive_fibonacci(i)) -------------------------------------------------------------------------------- /Day_6/lambda_functions.py: -------------------------------------------------------------------------------- 1 | x = lambda a : a + 10 2 | print(x(5)) -------------------------------------------------------------------------------- /Day_6/practice_pattern.py: -------------------------------------------------------------------------------- 1 | def pattern(n): 2 | for i in range(n+1): 3 | for j in range(i): 4 | print("*",end=" ") 5 | print() 6 | rows = int(input("enter number of rows:")) 7 | pattern(rows) -------------------------------------------------------------------------------- /Day_6/recursion_counter.py: -------------------------------------------------------------------------------- 1 | def counter(n): 2 | if n<=0: 3 | return n 4 | else: 5 | return n+counter(n-1) 6 | res = counter(5) 7 | print(res) -------------------------------------------------------------------------------- /Day_6/recursion_factorial_function.py: -------------------------------------------------------------------------------- 1 | def fact(n): 2 | if n == 0: 3 | return 1 4 | else: 5 | return n * fact(n-1) 6 | n = int(input("enter a value: ")) 7 | res = fact(n) 8 | print("factorial is",res) --------------------------------------------------------------------------------