├── .gitignore ├── Day001 ├── Exercises │ ├── ex01.md │ ├── ex01.py │ ├── ex02.md │ ├── ex02.py │ ├── ex03.md │ ├── ex03.py │ ├── ex04.md │ └── ex04.py ├── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ ├── lec04.py │ └── lec05.py └── Project │ ├── project.md │ └── project.py ├── Day002 ├── Exercises │ ├── ex01.md │ ├── ex01.py │ ├── ex02.md │ ├── ex02.py │ ├── ex03.md │ └── ex03.py ├── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ └── lec04.py └── Project │ ├── project.md │ └── project.py ├── Day003 ├── Exercises │ ├── ex01.md │ ├── ex01.py │ ├── ex02.md │ ├── ex02.py │ ├── ex03.md │ ├── ex03.py │ ├── ex04.md │ ├── ex04.py │ ├── ex05.md │ └── ex05.py ├── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ └── lec04.py └── Project │ ├── chest_flowchart.png │ ├── project.md │ └── project.py ├── Day004 ├── Exercises │ ├── ex01.md │ ├── ex01.py │ ├── ex02.md │ ├── ex02.py │ ├── ex03.md │ └── ex03.py ├── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ └── my_module.py └── Project │ ├── project.md │ └── project.py ├── Day005 ├── Exercises │ ├── ex01.md │ ├── ex01.py │ ├── ex02.md │ ├── ex02.py │ ├── ex03.md │ ├── ex03.py │ ├── ex04.md │ └── ex04.py ├── Lectures │ ├── lec01.py │ └── lec02.py └── Project │ ├── project.md │ └── project.py ├── Day006 ├── Challenges │ ├── ch01.md │ ├── ch01.py │ ├── ch02.md │ ├── ch02.py │ ├── ch03.md │ └── ch03.py ├── Lectures │ ├── lec01.py │ ├── lec02.md │ ├── lec02.py │ ├── lec03.md │ ├── lec03.py │ ├── lec04.md │ └── lec04.py └── Project │ ├── Reeborg World Tests │ ├── problem_world.json │ ├── problem_world2.json │ └── problem_world3.json │ ├── project.md │ └── project.py ├── Day007 ├── Challenges │ ├── Challenges.md │ ├── ch01.py │ ├── ch02.py │ ├── ch03.py │ ├── ch04.py │ └── hangman_flowchart.png └── Project │ ├── hangman_art.py │ ├── hangman_words.py │ ├── project.md │ └── project.py ├── Day008 ├── Exercises │ ├── ex01.md │ ├── ex01.py │ ├── ex02.md │ └── ex02.py ├── Lectures │ ├── lec01.py │ └── lec02.py └── Project │ ├── caesar_cipher_art.py │ ├── project.md │ ├── project.py │ ├── project01.py │ ├── project02.py │ └── project03.py ├── Day009 ├── Exercises │ ├── ex01.md │ ├── ex01.py │ ├── ex02.md │ └── ex02.py ├── Lectures │ ├── lec01.py │ └── lec02.py └── Project │ ├── auction_art.py │ ├── flowchart.png │ ├── project.md │ └── project.py ├── Day010 ├── Code_Along │ ├── calc01.py │ ├── calc02.py │ └── calc03.py ├── Exercises │ ├── ex.md │ └── ex.py ├── Lectures │ ├── lec01.py │ ├── lec02.py │ └── lec03.py └── Project │ ├── calc_art.py │ ├── project.md │ └── project.py ├── Day011 └── Capstone_Project │ ├── blackjack_art.py │ ├── project.md │ └── project.py ├── Day012 ├── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ ├── lec04.py │ ├── lec05.py │ ├── lec06.py │ └── lec07.py └── Project │ ├── game_art.py │ ├── project.md │ └── project.py ├── Day013 ├── Exercises │ ├── ex01.md │ ├── ex01.py │ ├── ex02.md │ ├── ex02.py │ ├── ex03.md │ └── ex03.py └── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ ├── lec04.py │ ├── lec05.py │ └── lec06.py ├── Day014 └── Project │ ├── game_art.py │ ├── game_data.py │ ├── project.md │ └── project.py ├── Day015 ├── Lectures │ └── lec01.py └── Project │ ├── coffee_machine_data.py │ ├── project.pdf │ └── project.py ├── Day016 ├── Lecture │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ ├── lec04.py │ └── module.py └── Project │ ├── coffee_maker.py │ ├── menu.py │ ├── money_machine.py │ ├── project.pdf │ └── project.py ├── Day017 ├── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ └── lec04.py └── Project │ └── Project01 │ ├── project.md │ ├── project.py │ ├── question_model.py │ ├── quiz_brain.py │ └── quiz_data.py ├── Day018 ├── Challenges │ ├── ch.md │ ├── ch01.py │ ├── ch02.py │ ├── ch03.py │ ├── ch04.py │ └── ch05.py ├── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ └── lec04.py └── Project │ ├── project.md │ └── project.py ├── Day019 ├── Challenges │ ├── ch.md │ └── ch.py ├── Lectures │ ├── lec01.py │ └── lec02.py └── Project │ ├── project.md │ └── project.py ├── Day020 └── Project │ ├── project.md │ ├── project.py │ ├── sketch_project.py │ └── snake.py ├── Day021 ├── Lecture │ ├── lec01.py │ └── lec02.py └── Project │ ├── food.py │ ├── project.md │ ├── project.py │ ├── scoreboard.py │ └── snake.py ├── Day022 └── Project │ ├── ball.py │ ├── paddle.py │ ├── project.md │ ├── project.py │ ├── scoreboard.py │ └── sketch_project.py ├── Day023 └── Capstone_Project │ ├── car_manager.py │ ├── player.py │ ├── project.md │ ├── project.py │ └── scoreboard.py ├── Day024 ├── Challenges │ ├── ch.md │ └── ch │ │ ├── data.txt │ │ ├── food.py │ │ ├── main.py │ │ ├── scoreboard.py │ │ └── snake.py ├── Lectures │ ├── lec01 │ │ ├── food.py │ │ ├── main.py │ │ ├── scoreboard.py │ │ └── snake.py │ ├── lec02 │ │ ├── main.py │ │ └── my_file.txt │ ├── lec03 │ │ ├── main.py │ │ └── my_file.txt │ ├── lec04 │ │ ├── main.py │ │ └── my_file.txt │ ├── lec05 │ │ ├── main.py │ │ └── my_file.txt │ ├── lec06 │ │ ├── main.py │ │ └── new_file.txt │ └── lec07 │ │ ├── Desktop │ │ └── my_file.txt │ │ └── main.py └── Project │ ├── Input │ ├── Letters │ │ └── starting_letter.docx │ └── Names │ │ └── invited_names.txt │ ├── Output │ └── ReadyToSend │ │ ├── example.docx │ │ ├── letter_for_Aang.docx │ │ ├── letter_for_Appa.docx │ │ ├── letter_for_Katara.docx │ │ ├── letter_for_Momo.docx │ │ ├── letter_for_Sokka.docx │ │ ├── letter_for_Toph.docx │ │ ├── letter_for_Uncle Iroh.docx │ │ └── letter_for_Zuko.docx │ ├── project.md │ └── project.py ├── Day025 ├── Challenge │ ├── ch.md │ ├── ch.py │ ├── color_data.csv │ └── squirrel_census.csv ├── Lectures │ ├── lec01 │ │ ├── main.py │ │ └── weather_data.csv │ ├── lec02 │ │ ├── main.py │ │ └── weather_data.csv │ └── lec03 │ │ ├── main.py │ │ └── score_data.csv └── Project │ ├── project.md │ ├── project.py │ ├── states.csv │ ├── states_to_learn.csv │ └── us_states.gif ├── Day026 ├── Exercises │ ├── ex01.md │ ├── ex01.py │ ├── ex02.md │ ├── ex02.py │ ├── ex03.md │ ├── ex03.py │ ├── ex04.md │ ├── ex04.py │ ├── ex05.md │ ├── ex05.py │ ├── file1.txt │ └── file2.txt ├── Lectures │ ├── lec01.py │ ├── lec02 │ │ ├── main.py │ │ ├── states.csv │ │ ├── states_to_learn.csv │ │ ├── us_states.gif │ │ └── wrong.png │ ├── lec03.py │ └── lec04.py └── Project │ ├── nato_phonetic_alphabet.csv │ ├── project.md │ └── project.py ├── Day027 ├── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ ├── lec04.py │ ├── lec05.py │ ├── lec06.py │ ├── lec07.py │ ├── lec08.py │ ├── lec09.py │ ├── lec10.py │ ├── lec11.py │ ├── lec12.py │ ├── lec13.py │ ├── lec14.py │ └── lec15.py └── Project │ ├── converter_application.png │ ├── project.md │ └── project.py ├── Day028 ├── Lectures │ └── lec01.py └── Project │ ├── pomodoro.png │ ├── project.md │ ├── project.py │ ├── project01.py │ ├── project02.py │ ├── project03.py │ ├── project04.py │ ├── project05.py │ ├── sounds │ ├── long_break_time.mp3 │ ├── short_break_time.mp3 │ └── work_time.mp3 │ └── tomato.png ├── Day029 ├── Lectures │ ├── lec01.py │ ├── lec02.py │ └── lec03.py └── Project │ ├── padlock.png │ ├── passwords.csv │ ├── project.md │ ├── project.py │ ├── project_img1.png │ └── project_img2.png ├── Day030 ├── Exercises │ ├── ex01.md │ ├── ex01.py │ ├── ex02.md │ ├── ex02.py │ └── ex03 │ │ ├── ex03.md │ │ ├── nato_phonetic_alphabet.csv │ │ └── project.py ├── Lectures │ ├── lec01 │ │ └── main.py │ ├── lec02 │ │ ├── file.txt │ │ └── main.py │ ├── lec03 │ │ ├── file.txt │ │ └── main.py │ ├── lec04 │ │ ├── file.txt │ │ └── main.py │ ├── lec05.py │ └── lec06 │ │ ├── data.json │ │ └── main.py └── Project │ ├── padlock.png │ ├── passwords.json │ ├── project.md │ ├── project.py │ └── project01.png ├── Day031 └── Capstone_Project │ ├── data │ ├── french_words.csv │ └── words_to_learn.csv │ ├── images │ ├── card_back.png │ ├── card_front.png │ ├── right.png │ └── wrong.png │ ├── img01.png │ ├── img02.png │ ├── img03.png │ ├── img04.gif │ ├── img05.gif │ ├── project.md │ └── project.py ├── Day032 ├── Challenges │ ├── ch.md │ ├── ch.py │ └── quotes.txt ├── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ └── lec04.py └── Project │ ├── birthdays.csv │ ├── letter_templates │ ├── letter_1.txt │ ├── letter_2.txt │ └── letter_3.txt │ ├── project.md │ └── project.py ├── Day033 ├── Challenges │ ├── background.png │ ├── ch.md │ ├── ch.py │ └── kanye.png ├── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ ├── lec04.py │ ├── lec05.py │ ├── lec06.py │ └── lec07.py └── Project │ ├── project.md │ └── project.py ├── Day034 ├── Lectures │ └── lec.py └── Project │ ├── data.py │ ├── images │ ├── false.png │ └── true.png │ ├── project.md │ ├── project.py │ ├── question_model.py │ ├── quiz_brain.py │ ├── ui.png │ └── ui.py ├── Day035 ├── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ └── lec04.py └── Project │ ├── project.md │ └── project.py ├── Day036 └── Project │ ├── project.md │ ├── project.py │ ├── project01.py │ └── project02.py ├── Day037 ├── Challenges │ ├── ch.md │ └── ch.py └── Lectures │ ├── lec01.py │ ├── lec02.py │ ├── lec03.py │ ├── lec04.py │ └── lec05.py ├── Day038 └── Challenge_Project │ ├── project.md │ ├── project.py │ ├── project01.py │ ├── project02.py │ └── step04.png ├── Day039 └── Capstone_Project │ ├── data_manager.py │ ├── flight_data.py │ ├── flight_search.py │ ├── notification_manager.py │ ├── project.md │ └── project.py ├── Day040 └── Capstone_Project │ ├── add_members.py │ ├── data_manager.py │ ├── flight_data.py │ ├── flight_search.py │ ├── notification_manager.py │ ├── project.md │ ├── project.py │ ├── project01.py │ ├── step01.png │ ├── step04.png │ └── text.py ├── Day041 ├── Lectures │ └── lec01.html ├── PlayBook │ └── playbook.html └── Project │ ├── contact_info.html │ ├── hobbies.html │ ├── index.html │ └── paula.png ├── Day042 ├── Challenges │ └── ch.html ├── Lectures │ ├── lec01.html │ └── lec02.html └── Project │ ├── contact_info.html │ ├── hobbies.html │ ├── index.html │ └── paula.png ├── Day043 ├── Challenges │ ├── ch01 │ │ ├── contact_info.html │ │ ├── css │ │ │ └── styles.css │ │ ├── hobbies.html │ │ ├── index.html │ │ └── paula.png │ └── ch02 │ │ ├── contact_info.html │ │ ├── css │ │ └── styles.css │ │ ├── hobbies.html │ │ ├── index.html │ │ └── paula.png ├── Lectures │ ├── lec01 │ │ ├── contact_info.html │ │ ├── hobbies.html │ │ ├── index.html │ │ └── paula.png │ ├── lec02 │ │ ├── contact_info.html │ │ ├── hobbies.html │ │ ├── index.html │ │ └── paula.png │ ├── lec03 │ │ ├── contact_info.html │ │ ├── hobbies.html │ │ ├── index.html │ │ └── paula.png │ ├── lec04 │ │ ├── contact_info.html │ │ ├── hobbies.html │ │ ├── index.html │ │ └── paula.png │ ├── lec05 │ │ ├── contact_info.html │ │ ├── hobbies.html │ │ ├── index.html │ │ └── paula.png │ └── lec06 │ │ ├── contact_info.html │ │ ├── css │ │ └── styles.css │ │ ├── hobbies.html │ │ ├── index.html │ │ └── paula.png └── Project │ ├── css │ └── styles.css │ ├── images │ ├── beans.png │ └── mm.jpg │ └── index.html └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.idea 2 | /venv/ 3 | -------------------------------------------------------------------------------- /Day001/Exercises/ex01.py: -------------------------------------------------------------------------------- 1 | print("Day 1 - Python Print Function") 2 | print("The function is declared like this:") 3 | print("print('what to print')") 4 | -------------------------------------------------------------------------------- /Day001/Exercises/ex02.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 | 6 | -------------------------------------------------------------------------------- /Day001/Exercises/ex03.py: -------------------------------------------------------------------------------- 1 | print(len(input("What is your name? "))) 2 | -------------------------------------------------------------------------------- /Day001/Exercises/ex04.md: -------------------------------------------------------------------------------- 1 | ## Variables 2 | 3 | # Instructions 4 | 5 | Write a program that switches the values stored in the variables a and b. 6 | 7 | **Warning.** Do not change the code on lines 1-3 and 10-12. Your program should work for different inputs. e.g. any value of a and b. 8 | 9 | # Example Input 10 | 11 | ``` 12 | a: 3 13 | ``` 14 | 15 | ``` 16 | b: 5 17 | ``` 18 | 19 | # Example Output 20 | 21 | ``` 22 | a: 5 23 | ``` 24 | 25 | ``` 26 | b: 3 27 | ``` 28 | 29 | e.g. When you hit **run**, this is what should happen: 30 | 31 | ![](https://cdn.fs.teachablecdn.com/tgdNl0iSqK6RpPyYZh9d) 32 | 33 | # Hint 34 | 35 | 1. You should not have to type any numbers in your code. 36 | 2. You might need to make some more variables. 37 | 38 | # Test Your Code 39 | 40 | Before checking the solution, try copy-pasting your code into this repl: 41 | 42 | [https://repl.it/@appbrewery/day-1-4-test-your-code](https://repl.it/@appbrewery/day-1-4-test-your-code) 43 | 44 | This repl includes my testing code that will check if your code meets this assignment's objectives. 45 | 46 | 47 | 48 | 49 | # Solution 50 | 51 | [https://repl.it/@appbrewery/day-1-4-solution](https://repl.it/@appbrewery/day-1-4-solution) 52 | -------------------------------------------------------------------------------- /Day001/Exercises/ex04.py: -------------------------------------------------------------------------------- 1 | # Don't change the lines below 2 | a = input("a: ") 3 | b = input("b: ") 4 | 5 | # Your code here: 6 | temp = a 7 | a = b 8 | b = a 9 | 10 | # Don't change the lines below 11 | print("a: " + a) 12 | print("b: " + b) 13 | -------------------------------------------------------------------------------- /Day001/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | print("Hello world!") 2 | -------------------------------------------------------------------------------- /Day001/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | print("Hello world!") 2 | print("Hello world!") 3 | print("Hello world!") 4 | print() 5 | 6 | print("Hello world!\nHello world!\nHello world!") 7 | print() 8 | 9 | print("Hello" + "Angela") 10 | print("Hello " + "Angela") 11 | print("Hello" + " Angela") 12 | print("Hello" + " " + "Angela") 13 | -------------------------------------------------------------------------------- /Day001/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | print("What is your name? ") 2 | print() 3 | 4 | input("What is your name? ") 5 | print() 6 | 7 | # input() will get user input in console 8 | # The print() will print the word "Hello " and the user input 9 | print("Hello " + input("What is your name? ")) 10 | print() 11 | -------------------------------------------------------------------------------- /Day001/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | name = input("What is your name? ") 2 | print(name) 3 | print() 4 | 5 | name = "Jack" 6 | print(name) 7 | 8 | name = "Angela" 9 | print(name) 10 | print() 11 | 12 | name = input("What is your name? ") 13 | length = len(name) 14 | print(length) 15 | -------------------------------------------------------------------------------- /Day001/Lectures/lec05.py: -------------------------------------------------------------------------------- 1 | user_name = input("What is your name? ") 2 | length1 = len(user_name) 3 | 4 | user_name = input("What is your name? ") 5 | length2 = len(user_name) 6 | 7 | print(length1) 8 | print(length2) 9 | -------------------------------------------------------------------------------- /Day001/Project/project.md: -------------------------------------------------------------------------------- 1 | ## Band Name Generator 2 | 3 | # Instructions 4 | 5 | 1. Create a greeting for your program. 6 | 2. Ask the user for the city that they grew up in. 7 | 3. Ask the user for the name of a pet. 8 | 4. Combine the name of their city and pet and show them their band name. 9 | 5. Make sure the input cursor shows on a new line, see the example at: [band-name-generator](https://band-name-generator-end.appbrewery.repl.run/) 10 | 11 | # Example Output 12 | 13 | ``` 14 | Welcome to the Band Name Generator. 15 | What's the name of the city you grew up in? 16 | > Itabira 17 | What's your pet's name? 18 | > Molly Marie 19 | Your band name could be Itabira Molly Marie 20 | ``` 21 | OBS.: `>` represents input 22 | -------------------------------------------------------------------------------- /Day001/Project/project.py: -------------------------------------------------------------------------------- 1 | # 1. Create a greeting for your program. 2 | print('Welcome to the Band Name Generator.') 3 | 4 | # 2. Ask the user for the city that they grew up in. 5 | print("What's the name of the city you grew up in?") 6 | city = input() 7 | 8 | # 3. Ask the user for the name of a pet. 9 | print("What's your pet's name?") 10 | pet = input() 11 | 12 | # 4. Combine the name of their city and pet and show them their band name. 13 | band = city + " " + pet 14 | print("Your band name could be " + band) 15 | -------------------------------------------------------------------------------- /Day002/Exercises/ex01.md: -------------------------------------------------------------------------------- 1 | ## Data Types 2 | 3 | # Instructions 4 | 5 | Write a program that adds the digits in a 2 digit number. e.g. if the input was 35, then the output should be 3 + 5 = 8 6 | 7 | **Warning.** Do not change the code on line 1. Your program should work for different inputs. e.g. any two-digit number. 8 | 9 | # Example Input 10 | 11 | ``` 12 | 39 13 | ``` 14 | 15 | # Example Output 16 | 17 | 3 + 9 = 12 18 | 19 | ``` 20 | 12 21 | ``` 22 | 23 | e.g. When you hit **run**, this is what should happen: 24 | 25 | ![](https://cdn.fs.teachablecdn.com/iyJTPDDRRJCB1gmdVQMS) 26 | 27 | # Hint 28 | 29 | 1. Try to find out the data type of two_digit_number. 30 | 2. Think about what you learnt about subscripting. 31 | 3. Think about type conversion. 32 | 33 | # Test Your Code 34 | 35 | Before checking the solution, try copy-pasting your code into this repl: 36 | 37 | [https://repl.it/@appbrewery/day-2-1-test-your-code](https://repl.it/@appbrewery/day-2-1-test-your-code) 38 | 39 | This repl includes my testing code that will check if your code meets this assignment's objectives. 40 | 41 | # Solution 42 | 43 | [https://repl.it/@appbrewery/day-2-1-solution](https://repl.it/@appbrewery/day-2-1-solution) 44 | -------------------------------------------------------------------------------- /Day002/Exercises/ex01.py: -------------------------------------------------------------------------------- 1 | two_digit_number = input("Type a two digit number: ") 2 | 3 | first_digit = int(two_digit_number[0]) 4 | second_digit = int(two_digit_number[1]) 5 | 6 | sum_digits = first_digit + second_digit 7 | print(sum_digits) 8 | -------------------------------------------------------------------------------- /Day002/Exercises/ex02.py: -------------------------------------------------------------------------------- 1 | # Don't change the lines below 2 | height = float(input('Enter your height (m): ')) 3 | weight = float(input('Enter your weight (kg): ')) 4 | 5 | # Your code here 6 | bmi = int(weight / height ** 2) 7 | print('Your BMI is: ' + str(bmi)) 8 | -------------------------------------------------------------------------------- /Day002/Exercises/ex03.py: -------------------------------------------------------------------------------- 1 | age = int(input("What is your current age? ")) 2 | 3 | years_left = 90 - age 4 | months_left = round(years_left * 12) 5 | weeks_left = round(years_left * 52) 6 | days_left = round(years_left * 365) 7 | print(f'You have {days_left} days, {weeks_left} weeks, and {months_left} months left.') 8 | -------------------------------------------------------------------------------- /Day002/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | # Data Types 2 | 3 | # String 4 | print("Hello"[0]) 5 | print("Hello"[4]) 6 | print("123" + "345") 7 | print("hello" + "world") 8 | print() 9 | 10 | # Integer 11 | print(123 + 345) 12 | print(123_456_789) 13 | print() 14 | 15 | # Float 16 | print(3.14159) 17 | print() 18 | 19 | # Boolean 20 | print(True) 21 | print(False) 22 | -------------------------------------------------------------------------------- /Day002/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | num_char = len(input("What is your name? ")) 2 | # print("Your name has " + num_char + "characters.") # TypeError 3 | 4 | print(type(num_char)) 5 | new_num_char = str(num_char) 6 | print("Your name has " + new_num_char + " characters.") 7 | print() 8 | 9 | a = 123 10 | print(type(a)) 11 | 12 | a = str(123) 13 | print(type(a)) 14 | 15 | a = float(123) 16 | print(type(a)) 17 | print() 18 | 19 | print(70 + float("100.5")) 20 | print(str(70) + str(100)) 21 | -------------------------------------------------------------------------------- /Day002/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | print(3 + 5) 2 | print(7 - 4) 3 | print(3 * 2) 4 | print(6 / 3) 5 | print(type(6 / 3)) 6 | print(2 ** 2) 7 | print(2 ** 3) 8 | print() 9 | 10 | # PEMDAS 11 | # () 12 | # ** 13 | # * / 14 | # + - 15 | 16 | print(3 * 3 + 3 / 3 - 3) 17 | print(3 * (3 + 3) / 3 - 3) 18 | print() 19 | -------------------------------------------------------------------------------- /Day002/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | print(8 / 3) 2 | print(int(8 / 3)) 3 | print(round(8 / 3)) 4 | print(round(8 / 3, 2)) 5 | print(round(2.666666666666, 2)) 6 | print() 7 | 8 | print(8 // 3) 9 | print(type(8 // 3)) 10 | print(type(8 / 3)) 11 | print(type(4 / 2)) 12 | print() 13 | 14 | result = 4 / 2 15 | result /= 2 16 | print(result) 17 | 18 | score = 0 19 | 20 | # User scores a point 21 | score += 1 22 | print(score) 23 | print("Your score is " + str(score) ) 24 | print() 25 | 26 | score = 0 27 | height = 1.8 28 | is_winning = True 29 | 30 | # f-string 31 | print(f"Your score is {score}, your height is {height}, you are winning is {is_winning}") 32 | 33 | 34 | -------------------------------------------------------------------------------- /Day002/Project/project.md: -------------------------------------------------------------------------------- 1 | ## Tip Calculator 2 | 3 | # Instructions 4 | 5 | 1. Create a greeting for your program. 6 | 2. Ask for the bill 7 | 3. Ask for the tip percentage 8 | 4. Ask for the number of people to split the bill with. 9 | 5. Calculate the total bill and the bill per person. 10 | 6. Display the bill per person with 2 decimal places. 11 | 12 | - If the bill was $150.00, split between 5 people, with 12% tip. 13 | - Each person should pay (150.00 / 5) * 1.12 = 33.6 14 | - Format the result to 2 decimal places = 33.60 15 | 16 | ### Tip: 17 | There are 2 ways to round a number. You might have to do some Googling to solve this. 18 | 19 | ### HINT 1: 20 | [google](https://www.google.com/search?q=how+to+round+number+to+2+decimal+places+python&oq=how+to+round+number+to+2+decimal) 21 | 22 | ### HINT 2: 23 | [kite](https://www.kite.com/python/answers/how-to-limit-a-float-to-two-decimal-places-in-python) 24 | 25 | # Example Output 26 | ``` 27 | Welcome to the tip calculator. 28 | What was the total bill? $ > 124.56 29 | What percentage tip would you like to give? 10, 12 or 15? > 12 30 | How many people to split the bill? > 7 31 | Each person should pay: $19.93 32 | ``` 33 | OBS.: `>` represents input 34 | $ and > are separated otherwise they are font ligated. 35 | -------------------------------------------------------------------------------- /Day002/Project/project.py: -------------------------------------------------------------------------------- 1 | # 1. Create a greeting for your program. 2 | print('Welcome to the tip calculator.') 3 | 4 | # 2. Ask for the bill 5 | prompt = 'What was the total bill? $' 6 | bill = float(input(prompt)) 7 | 8 | # 3. Ask for the tip percentage 9 | prompt = 'What percentage tip would you like to give? 10, 12 or 15? ' 10 | tip_rate = int(input(prompt)) / 100 11 | 12 | # 4. Ask for the number of people to split the bill with. 13 | prompt = 'How many people to split the bill? ' 14 | people = int(input(prompt)) 15 | 16 | # 5. Calculate the total bill and the bill per person. 17 | total_rate = 1 + tip_rate 18 | total_bill = bill * total_rate 19 | bill_per_person = total_bill / people 20 | 21 | # 6. Display the bill per person with 2 decimal places. 22 | print(f'Each person should pay: ${bill_per_person:.2f}') 23 | -------------------------------------------------------------------------------- /Day003/Exercises/ex01.py: -------------------------------------------------------------------------------- 1 | number = int(input("Which number do you want to check? ")) 2 | 3 | if number % 2 == 0: 4 | print('This is an even number.') 5 | else: 6 | print('This is an odd number.') 7 | -------------------------------------------------------------------------------- /Day003/Exercises/ex02.py: -------------------------------------------------------------------------------- 1 | height = float(input("Enter your height in m: ")) 2 | weight = float(input("Enter your weight in kg: ")) 3 | 4 | bmi = round(weight / height ** 2) 5 | underweight = f"Your BMI is {bmi}, you are underweight." 6 | normal_weight = f"Your BMI is {bmi}, you have a normal weight." 7 | overweight = f"Your BMI is {bmi}, you are slightly overweight." 8 | obese = f"Your BMI is {bmi}, you are obese." 9 | clinically_obese = f"Your BMI is {bmi}, you are clinically obese." 10 | 11 | if bmi < 18.5: 12 | print(underweight) 13 | elif bmi < 25: 14 | print(normal_weight) 15 | elif bmi < 30: 16 | print(overweight) 17 | elif bmi < 35: 18 | print(obese) 19 | else: 20 | print(clinically_obese) 21 | -------------------------------------------------------------------------------- /Day003/Exercises/ex03.py: -------------------------------------------------------------------------------- 1 | year = int(input("Which year do you want to check? ")) 2 | 3 | if year % 400 == 0: 4 | print('Leap year.') 5 | elif year % 100 == 0: 6 | print('Not leap year.') 7 | elif year % 4 == 0: 8 | print('Leap year.') 9 | else: 10 | print('Not leap year.') 11 | -------------------------------------------------------------------------------- /Day003/Exercises/ex04.py: -------------------------------------------------------------------------------- 1 | print("Welcome to Python Pizza Deliveries!") 2 | size = input("What size pizza do you want? S, M, or L ") 3 | add_pepperoni = input("Do you want pepperoni? Y or N ") 4 | extra_cheese = input("Do you want extra cheese? Y or N ") 5 | 6 | if size == 'S': 7 | price = 15 8 | if add_pepperoni == 'Y': 9 | price += 2 10 | elif size == 'M': 11 | price = 20 12 | if add_pepperoni == 'Y': 13 | price += 3 14 | else: 15 | price = 25 16 | if add_pepperoni == 'Y': 17 | price += 3 18 | 19 | if extra_cheese == 'Y': 20 | price += 1 21 | 22 | print(f'Your final bill is: ${price}') 23 | -------------------------------------------------------------------------------- /Day003/Exercises/ex05.py: -------------------------------------------------------------------------------- 1 | print("Welcome to the Love Calculator!") 2 | print("What is your name?") 3 | name1 = input().lower() 4 | print("What is their name?") 5 | name2 = input().lower() 6 | 7 | name = name1 + name2 8 | true = name.count('t') + name.count('r') + name.count('u') + name.count('e') 9 | love = name.count('l') + name.count('o') + name.count('v') + name.count('e') 10 | 11 | score = int(f'{true}{love}') 12 | 13 | if score < 10 or score > 90: 14 | print(f'Your score is {score}, you go together like coke and mentos.') 15 | elif 40 < score < 50: 16 | print(f'Your score is {score}, you are alright together.') 17 | else: 18 | print(f'Your score is {score}.') 19 | -------------------------------------------------------------------------------- /Day003/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | water_level = int(input('Water level? ')) 2 | if water_level > 80: 3 | print('Drain water') 4 | else: 5 | print('Continue') 6 | print() 7 | 8 | print("Welcome to the roller coaster!") 9 | height = int(input("What is your height in cm? ")) 10 | 11 | if height >= 120: 12 | print("You an ride the roller coaster!") 13 | else: 14 | print("Sorry, you have to grow taller before you can ride.") 15 | print() 16 | 17 | print(height > 120) 18 | print(height == 120) 19 | -------------------------------------------------------------------------------- /Day003/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | print("Welcome to the roller coaster!") 2 | height = int(input("What is your height in cm? ")) 3 | 4 | if height >= 120: 5 | print("You can ride the roller coaster!") 6 | age = int(input("What is your age? ")) 7 | if age < 12: 8 | print("Please pay $5") 9 | elif age <= 18: 10 | print("Please pay $7") 11 | else: 12 | print("Please pay $12") 13 | else: 14 | print("Sorry, you have to grow taller before you can ride.") 15 | -------------------------------------------------------------------------------- /Day003/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | print("Welcome to the roller coaster!") 2 | height = int(input("What is your height in cm? ")) 3 | 4 | if height >= 120: 5 | print("You can ride the roller coaster!") 6 | age = int(input("What is your age? ")) 7 | if age < 12: 8 | bill = 5 9 | print("Child tickets are $5") 10 | elif age <= 18: 11 | bill = 7 12 | print("Youth tickets are $7") 13 | else: 14 | bill = 12 15 | print("Adult tickets are $12") 16 | 17 | wants_photo = input("Do you want a photo taken? Y or N. ") 18 | if wants_photo == 'Y': 19 | bill += 3 20 | 21 | print(f"Your final bill is ${bill}") 22 | else: 23 | print("Sorry, you have to grow taller before you can ride.") 24 | -------------------------------------------------------------------------------- /Day003/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | a = 12 2 | print(a > 15) 3 | print(a > 10) 4 | print(a > 10 and a < 13) 5 | print(a > 15 and a < 13) 6 | print() 7 | 8 | print(not a > 15) 9 | print() 10 | 11 | print("Welcome to the roller coaster!") 12 | height = int(input("What is your height in cm? ")) 13 | 14 | if height >= 120: 15 | print("You can ride the roller coaster!") 16 | age = int(input("What is your age? ")) 17 | if age < 12: 18 | bill = 5 19 | print("Child tickets are $5") 20 | elif age <= 18: 21 | bill = 7 22 | print("Youth tickets are $7") 23 | elif age >= 45 and age <= 55: 24 | bill = 0 25 | print("Everything is going to be OK. Have a free ride on us!") 26 | else: 27 | bill = 12 28 | print("Adult tickets are $12") 29 | 30 | wants_photo = input("Do you want a photo taken? Y or N. ") 31 | if wants_photo == 'Y': 32 | bill += 3 33 | 34 | print(f"Your final bill is ${bill}") 35 | else: 36 | print("Sorry, you have to grow taller before you can ride.") 37 | 38 | -------------------------------------------------------------------------------- /Day003/Project/chest_flowchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day003/Project/chest_flowchart.png -------------------------------------------------------------------------------- /Day003/Project/project.md: -------------------------------------------------------------------------------- 1 | # Project name 2 | 3 | # Instructions 4 | Create a program that simulates Choose your own adventure game. 5 | Use the following flowchart to display the output based on what the user chooses. 6 | 7 | ![](chest_flowchart.png) 8 | 9 | -------------------------------------------------------------------------------- /Day004/Exercises/ex01.md: -------------------------------------------------------------------------------- 1 | ## Heads or Tails 2 | 3 | # Instructions 4 | 5 | You are going to write a virtual coin toss program. It will randomly tell the user "Heads" or "Tails". 6 | 7 | **Important**, the first letter should be capitalised and spelt exactly like in the example e.g. Heads, not heads. 8 | 9 | There are many ways of doing this. But to practice what we learnt in the last lesson, you should generate a random number, either 0 or 1. Then use that number to print out Heads or Tails. 10 | 11 | e.g. 12 | 1 means Heads 13 | 0 means Tails 14 | 15 | # Example Output 16 | 17 | ``` 18 | Heads 19 | ``` 20 | 21 | or 22 | 23 | ``` 24 | Tails 25 | ``` 26 | 27 | 28 | # Solution 29 | 30 | [https://repl.it/@appbrewery/day-4-1-solution](https://repl.it/@appbrewery/day-4-1-solution) 31 | -------------------------------------------------------------------------------- /Day004/Exercises/ex01.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | coin = random.randint(0, 1) 4 | 5 | if coin == 0: 6 | print('Tails') 7 | else: 8 | print('Heads') 9 | -------------------------------------------------------------------------------- /Day004/Exercises/ex02.md: -------------------------------------------------------------------------------- 1 | ## Who's Paying 2 | 3 | # Instructions 4 | 5 | You are going to write a program which will select a random name from a list of names. The person selected will have to pay for everybody's food bill. 6 | 7 | **Important**: You are not allowed to use the `choice()` function. 8 | 9 | **Line 2** splits the string `names_string` into individual names and puts them inside a **List** called `names`. For this to work, you must enter all the names as name separated by a space. e.g. name1 name2 name3 10 | 11 | # Example Input 12 | 13 | ``` 14 | Angela Ben Jenny Michael Chloe 15 | ``` 16 | 17 | # Example Output 18 | 19 | ``` 20 | Michael is going to buy the meal today! 21 | ``` 22 | 23 | 24 | # Hint 25 | 26 | 1. You might need the help of the `len()` function. 27 | 28 | [https://stackoverflow.com/questions/1712227/how-do-i-get-the-number-of-elements-in-a-list](https://stackoverflow.com/questions/1712227/how-do-i-get-the-number-of-elements-in-a-list) 29 | 30 | 2. Remember that Lists start at index 0! 31 | 32 | # Solution 33 | 34 | [https://repl.it/@appbrewery/day-4-2-solution](https://repl.it/@appbrewery/day-4-2-solution) 35 | -------------------------------------------------------------------------------- /Day004/Exercises/ex02.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | names_string = input("Give me everybody's names, separated by a space. ") 4 | names = names_string.split() 5 | 6 | index = random.randint(0, len(names) - 1) 7 | print(f'{names[index]} is going to buy the meal today!') 8 | -------------------------------------------------------------------------------- /Day004/Exercises/ex03.py: -------------------------------------------------------------------------------- 1 | # Don't change the code below 2 | row1 = ["⬜️","⬜️","⬜️"] 3 | row2 = ["⬜️","⬜️","⬜️"] 4 | row3 = ["⬜️","⬜️","⬜️"] 5 | map_ = [row1, row2, row3] 6 | print(f"{row1}\n{row2}\n{row3}") 7 | position = input("Where do you want to put the treasure? ") 8 | 9 | # Write your code below this row 10 | y = int(position[0]) - 1 11 | x = int(position[1]) - 1 12 | map_[x][y] = 'X' 13 | 14 | # Don't change the code below 15 | print(f"{row1}\n{row2}\n{row3}") 16 | -------------------------------------------------------------------------------- /Day004/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | import random 2 | import my_module 3 | 4 | random_integer = random.randint(1, 10) 5 | print(random_integer) 6 | print() 7 | 8 | print(my_module.pi) 9 | print() 10 | 11 | random_float = random.random() 12 | print(random_float) 13 | print(random_float * 5) 14 | print() 15 | 16 | love_score = random.randint(1, 100) 17 | print(f"Your love score is {love_score}") 18 | -------------------------------------------------------------------------------- /Day004/Lectures/my_module.py: -------------------------------------------------------------------------------- 1 | pi = 3.141592653589793 2 | -------------------------------------------------------------------------------- /Day004/Project/project.md: -------------------------------------------------------------------------------- 1 | # Rock Paper Scissors Game 2 | 3 | # Instructions 4 | Use the code given to create a rock-paper-scissors game. 5 | Remember the rules: 6 | - Rock wins from scissors. 7 | - Paper wins from rock. 8 | - Scissors win from paper. 9 | 10 | If the user types an invalid number (not 0, 1 or 2) catch and print an error message. 11 | 12 | # Example Output 13 | 14 | ``` 15 | What do you choose? 0-rock, 1-paper, 2-scissors: > 0 16 | You chose: 17 | 18 | _______ 19 | ---' ____) 20 | (_____) 21 | (_____) 22 | (____) 23 | ---.__(___) 24 | 25 | Computer chose: 26 | 27 | _______ 28 | ---' ____)____ 29 | ______) 30 | __________) 31 | (____) 32 | ---.__(___) 33 | 34 | You win! 35 | ``` 36 | OBS.: `>` represents input 37 | -------------------------------------------------------------------------------- /Day005/Exercises/ex01.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 | 6 | # Write your code below this row 7 | count = 0 8 | sum_ = 0 9 | for student_height in student_heights: 10 | sum_ += student_height 11 | count += 1 12 | avg_height = round(sum_ / count) 13 | 14 | print(f'The average height is {avg_height}') 15 | -------------------------------------------------------------------------------- /Day005/Exercises/ex02.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 | 6 | # Write your code below this row 7 | maximum = -1 8 | for score in student_scores: 9 | if score > maximum: 10 | maximum = score 11 | 12 | print(f'The highest score in the class is: {maximum}') 13 | -------------------------------------------------------------------------------- /Day005/Exercises/ex03.md: -------------------------------------------------------------------------------- 1 | ## Adding Evens 2 | 3 | # Instructions 4 | 5 | You are going to write a program that calculates the sum of all the even numbers from 1 to 100, including 2 and 100. 6 | 7 | e.g. 2 + 4 + 6 + 8 +10 ... + 98 + 100 8 | 9 | Important, there should only be 1 print statement in your console output. It should just print the final total and not every step of the calculation. 10 | 11 | # Hint 12 | 13 | 1. There are quite a few ways of solving this problem, but you will need to use the `range()` function in any of the solutions. 14 | 15 | # Solution 16 | 17 | [https://repl.it/@appbrewery/day-5-3-solution](https://repl.it/@appbrewery/day-5-3-solution) 18 | -------------------------------------------------------------------------------- /Day005/Exercises/ex03.py: -------------------------------------------------------------------------------- 1 | sum_evens = 0 2 | for num in range(2, 101, 2): 3 | sum_evens += num 4 | print(f'The sum of even numbers from 1 to 100 is: {sum_evens}') 5 | -------------------------------------------------------------------------------- /Day005/Exercises/ex04.md: -------------------------------------------------------------------------------- 1 | ## FizzBuzz 2 | 3 | # Instructions 4 | 5 | You are going to write a program that automatically prints the solution to the FizzBuzz game. 6 | 7 | `Your program should print each number from 1 to 100 in turn.` 8 | 9 | `When the number is divisible by 3 then instead of printing the number it should print "Fizz".` 10 | 11 | `When the number is divisible by 5, then instead of printing the number it should print "Buzz".` 12 | 13 | `And if the number is divisible by both 3 and 5 e.g. 15 then instead of the number it should print "FizzBuzz"` 14 | 15 | e.g. it might start off like this: 16 | 17 | ``` 18 | `1 19 | 2 20 | Fizz 21 | 4 22 | Buzz 23 | Fizz 24 | 7 25 | 8 26 | Fizz 27 | Buzz 28 | 11 29 | Fizz 30 | 13 31 | 14 32 | FizzBuzz` 33 | ``` 34 | 35 | `.... etc.` 36 | 37 | # Hint 38 | 39 | 1. Remember your answer should start from 1 and go up to and including 100. 40 | 41 | 2. Each number/text should be printed on a separate line. 42 | 43 | # Solution 44 | 45 | [https://repl.it/@appbrewery/day-5-4-solution](https://repl.it/@appbrewery/day-5-4-solution) 46 | 47 | Alternatively: [https://en.wikipedia.org/wiki/Fizz_buzz](https://en.wikipedia.org/wiki/Fizz_buzz) 48 | 49 | -------------------------------------------------------------------------------- /Day005/Exercises/ex04.py: -------------------------------------------------------------------------------- 1 | for number in range(1, 101): 2 | if number % 3 == 0 and number % 5 == 0: 3 | print('FizzBuzz') 4 | elif number % 3 == 0: 5 | print('Fizz') 6 | elif number % 5 == 0: 7 | print('Buzz') 8 | else: 9 | print(number) 10 | -------------------------------------------------------------------------------- /Day005/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | fruits = ["Apple", "Peach", "Pear"] 2 | for fruit in fruits: 3 | print(fruit) 4 | print(fruit + " Pie") 5 | print(fruits) 6 | -------------------------------------------------------------------------------- /Day005/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | for number in range(1, 11): 2 | print(number, end=' ') 3 | print('\n') 4 | 5 | for number in range(1, 11, 3): 6 | print(number, end=' ') 7 | print('\n') 8 | 9 | total = 0 10 | for number in range(1, 101): 11 | total += number 12 | print(total) 13 | -------------------------------------------------------------------------------- /Day005/Project/project.md: -------------------------------------------------------------------------------- 1 | # PyPassword Generator 2 | 3 | # Instructions 4 | Your program should generate a password given the user specifications. 5 | Use the code given to get started. 6 | 7 | You can do it two ways: 8 | - Easy way 9 | - Hard way 10 | 11 | ### Easy way 12 | The order of the characters is not random first is the letters than the symbols and then the numbers. 13 | 14 | ### Hard way 15 | The order of the characters is completely random. 16 | 17 | # Example Output 18 | 19 | ``` 20 | Welcome to the PyPassword Generator! 21 | How many letters would you like in your password? > 4 22 | How many symbols would you like? > 2 23 | How many numbers would you like? > 3 24 | The easy password is: LxqU$*026 25 | The hard password is: *2q0x$6LU 26 | ``` 27 | OBS.: `>` indicates user input. 28 | -------------------------------------------------------------------------------- /Day006/Challenges/ch01.md: -------------------------------------------------------------------------------- 1 | # Reeborg's World 2 | 3 | ## Instructions 4 | Go to the following link: [Reeborg's World Challenge 1](https://reeborg.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Hurdle%201&url=worlds%2Ftutorial_en%2Fhurdle1.json) and pass the code from [ch01.py](ch01.py) to the program. 5 | You are supposed to make the robot complete the maze. 6 | -------------------------------------------------------------------------------- /Day006/Challenges/ch01.py: -------------------------------------------------------------------------------- 1 | # Observation: You need to run the code below on the 2 | # https://reeborg.ca/ website on the ch.md file. 3 | 4 | def turn_right(): 5 | turn_left() 6 | turn_left() 7 | turn_left() 8 | 9 | 10 | def hurdle(): 11 | move() 12 | turn_left() 13 | move() 14 | turn_right() 15 | move() 16 | turn_right() 17 | move() 18 | turn_left() 19 | 20 | 21 | for _ in range(6): 22 | hurdle() 23 | -------------------------------------------------------------------------------- /Day006/Challenges/ch02.md: -------------------------------------------------------------------------------- 1 | # Reeborg's World 2 | 3 | ## Instructions 4 | Go to the following link: [Reeborg's World Challenge 2](https://reeborg.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Hurdle%203&url=worlds%2Ftutorial_en%2Fhurdle3.json) and pass the code from [ch02.py](ch02.py) to the program. 5 | You are supposed to make the robot complete the maze. 6 | -------------------------------------------------------------------------------- /Day006/Challenges/ch02.py: -------------------------------------------------------------------------------- 1 | # Observation: You need to run the code below on the 2 | # https://reeborg.ca/ website on the ch02.md file. 3 | 4 | def turn_right(): 5 | turn_left() 6 | turn_left() 7 | turn_left() 8 | 9 | 10 | def jump(): 11 | turn_left() 12 | move() 13 | turn_right() 14 | move() 15 | turn_right() 16 | move() 17 | turn_left() 18 | 19 | 20 | while not at_goal(): 21 | if front_is_clear(): 22 | move() 23 | elif wall_in_front(): 24 | jump() 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Day006/Challenges/ch03.md: -------------------------------------------------------------------------------- 1 | # Reeborg's World 2 | 3 | ## Instructions 4 | Go to the following link: [Reeborg's World Challenge 3](https://reeborg.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Hurdle%204&url=worlds%2Ftutorial_en%2Fhurdle4.json) and pass the code from [ch03.py](ch03.py) to the program. 5 | You are supposed to make the robot complete the maze. 6 | -------------------------------------------------------------------------------- /Day006/Challenges/ch03.py: -------------------------------------------------------------------------------- 1 | # Observation: You need to run the code below on the 2 | # https://reeborg.ca/ website on the ch03.md file. 3 | 4 | def turn_right(): 5 | turn_left() 6 | turn_left() 7 | turn_left() 8 | 9 | 10 | def jump(): 11 | turn_left() 12 | while wall_on_right(): 13 | move() 14 | turn_right() 15 | move() 16 | turn_right() 17 | while front_is_clear(): 18 | move() 19 | turn_left() 20 | 21 | 22 | while not at_goal(): 23 | if front_is_clear(): 24 | move() 25 | elif wall_in_front(): 26 | jump() 27 | -------------------------------------------------------------------------------- /Day006/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | print("Hello") 2 | num_char = len("Hello") 3 | print(num_char) 4 | print() 5 | 6 | 7 | def my_function(): 8 | print("Hello") 9 | print("Bye") 10 | 11 | 12 | my_function() 13 | -------------------------------------------------------------------------------- /Day006/Lectures/lec02.md: -------------------------------------------------------------------------------- 1 | # Reeborg's World 2 | 3 | ## Instructions 4 | Go to the following link: [Reeborg's World](https://reeborg7.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Alone&url=worlds%2Ftutorial_en%2Falone.json) and pass the code from [lec02.py](lec02.py) to the program. 5 | Each comment indicates a different run example of the program. 6 | -------------------------------------------------------------------------------- /Day006/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | # Observation: You need to run the codes below on the https://reeborg.ca/ 2 | # More info is at the lec04.md file 3 | 4 | # First 5 | move() 6 | move() 7 | move() 8 | turn_left() 9 | move() 10 | move() 11 | move() 12 | 13 | # Second 14 | move() 15 | move() 16 | turn_left() 17 | turn_left() 18 | move() 19 | move() 20 | turn_left() 21 | turn_left() 22 | 23 | 24 | # Third 25 | def move_twice(): 26 | move() 27 | move() 28 | 29 | 30 | def turn_around(): 31 | turn_left() 32 | turn_left() 33 | 34 | 35 | move_twice() 36 | turn_around() 37 | move_twice() 38 | turn_around() 39 | 40 | 41 | # Forth 42 | def turn_right(): 43 | turn_left() 44 | turn_left() 45 | turn_left() 46 | 47 | 48 | turn_right() 49 | 50 | 51 | # Fifth 52 | def turn_right(): 53 | turn_left() 54 | turn_left() 55 | turn_left() 56 | 57 | 58 | def draw_square(): 59 | turn_left() 60 | move() 61 | turn_right() 62 | move() 63 | turn_right() 64 | move() 65 | turn_right() 66 | move() 67 | 68 | 69 | draw_square() 70 | -------------------------------------------------------------------------------- /Day006/Lectures/lec03.md: -------------------------------------------------------------------------------- 1 | # Reeborg's World 2 | 3 | ## Instructions 4 | Go to the following link: [Reeborg's World Hurdle 1](https://reeborg.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Hurdle%201&url=worlds%2Ftutorial_en%2Fhurdle1.json) and pass the code from [lec03.py](lec03.py) to the program. 5 | -------------------------------------------------------------------------------- /Day006/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | # Observation: You need to run the code below on the 2 | # https://reeborg.ca/ website on the lec03.md file. 3 | 4 | def turn_right(): 5 | turn_left() 6 | turn_left() 7 | turn_left() 8 | 9 | 10 | def jump(): 11 | move() 12 | turn_left() 13 | move() 14 | turn_right() 15 | move() 16 | turn_right() 17 | move() 18 | turn_left() 19 | 20 | 21 | number_of_hurdles = 6 22 | while number_of_hurdles > 0: 23 | jump() 24 | number_of_hurdles -= 1 25 | print(number_of_hurdles) 26 | -------------------------------------------------------------------------------- /Day006/Lectures/lec04.md: -------------------------------------------------------------------------------- 1 | # Reeborg's World 2 | 3 | ## Instructions 4 | Go to the following link: [Reeborg's World Hurdle 1](https://reeborg.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Hurdle%202&url=worlds%2Ftutorial_en%2Fhurdle2.json) and pass the code from [lec04.py](lec04.py) to the program. 5 | -------------------------------------------------------------------------------- /Day006/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | # Observation: You need to run the code below on the 2 | # https://reeborg.ca/ website on the lec04.md file. 3 | 4 | def turn_right(): 5 | turn_left() 6 | turn_left() 7 | turn_left() 8 | 9 | 10 | def jump(): 11 | move() 12 | turn_left() 13 | move() 14 | turn_right() 15 | move() 16 | turn_right() 17 | move() 18 | turn_left() 19 | 20 | 21 | while not at_goal(): 22 | jump() 23 | -------------------------------------------------------------------------------- /Day006/Project/project.md: -------------------------------------------------------------------------------- 1 | # Reeborg's Maze 2 | 3 | # Instructions 4 | Go to the following link: [Reeborg's World Maze](https://reeborg.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Maze&url=worlds%2Ftutorial_en%2Fmaze1.json) and pass the code from [project.py](project.py) to the program. 5 | 6 | Use the Reeborg World Tests Folder to load to the website the edge cases. 7 | 8 | # Example Output 9 | -------------------------------------------------------------------------------- /Day006/Project/project.py: -------------------------------------------------------------------------------- 1 | # Observation: You need to run the code below on the 2 | # https://reeborg.ca/ website on the project.md file. 3 | def turn_right(): 4 | turn_left() 5 | turn_left() 6 | turn_left() 7 | 8 | 9 | def robot_move(): 10 | if right_is_clear(): 11 | turn_right() 12 | move() 13 | elif front_is_clear(): 14 | move() 15 | else: 16 | turn_left() 17 | 18 | 19 | while front_is_clear(): 20 | move() 21 | while not at_goal(): 22 | robot_move() 23 | -------------------------------------------------------------------------------- /Day007/Challenges/ch01.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | word_list = ["aardvark", "baboon", "camel"] 4 | 5 | chosen_word = random.choice(word_list) 6 | 7 | guess = input('Enter a letter: ').lower() 8 | while len(guess) != 1 or not guess.isalpha(): 9 | print("Please enter a single letter!") 10 | guess = input('Enter a letter: ').lower() 11 | 12 | for letter in chosen_word: 13 | if letter == guess: 14 | print('Right') 15 | else: 16 | print('Wrong') 17 | 18 | -------------------------------------------------------------------------------- /Day007/Challenges/ch02.py: -------------------------------------------------------------------------------- 1 | import random 2 | word_list = ["aardvark", "baboon", "camel"] 3 | chosen_word = random.choice(word_list) 4 | word_length = len(chosen_word) 5 | 6 | # Testing code 7 | print(f'Pssst, the solution is: {chosen_word}.') 8 | display = ['_'] * word_length 9 | print(display) 10 | 11 | guess = input('Enter a letter: ').lower() 12 | while len(guess) != 1 or not guess.isalpha(): 13 | print("Please enter a single letter!") 14 | guess = input('Enter a letter: ').lower() 15 | 16 | for idx in range(word_length): 17 | if chosen_word[idx] == guess: 18 | display[idx] = chosen_word[idx] 19 | 20 | print(display) 21 | -------------------------------------------------------------------------------- /Day007/Challenges/ch03.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | 4 | def get_guess(): 5 | user_guess = input('Enter a letter: ').lower() 6 | while len(user_guess) != 1 or not user_guess.isalpha(): 7 | print("Please enter a single letter!") 8 | user_guess = input('Enter a letter: ').lower() 9 | return user_guess 10 | 11 | 12 | word_list = ["aardvark", "baboon", "camel"] 13 | chosen_word = random.choice(word_list) 14 | word_length = len(chosen_word) 15 | # Testing code 16 | print(f'Pssst, the solution is {chosen_word}.') 17 | 18 | # Create blanks 19 | display = ['_'] * word_length 20 | 21 | while '_' in display: 22 | print(display) 23 | guess = get_guess() 24 | for idx in range(word_length): 25 | letter = chosen_word[idx] 26 | if letter == guess: 27 | display[idx] = letter 28 | 29 | print(display) 30 | print('You win!') 31 | -------------------------------------------------------------------------------- /Day007/Challenges/hangman_flowchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day007/Challenges/hangman_flowchart.png -------------------------------------------------------------------------------- /Day008/Exercises/ex01.py: -------------------------------------------------------------------------------- 1 | # Write your code below this line 2 | import math 3 | 4 | 5 | def paint_calc(height, width, cover): 6 | cans = math.ceil(height * width / cover) 7 | cans_name = 'can' 8 | if cans != 1: 9 | cans_name += 's' 10 | print(f"You'll need {cans} {cans_name} of paint") 11 | 12 | 13 | # Don't change the code below 14 | test_h = int(input("Height of wall: ")) 15 | test_w = int(input("Width of wall: ")) 16 | coverage = 5 17 | paint_calc(height=test_h, width=test_w, cover=coverage) 18 | -------------------------------------------------------------------------------- /Day008/Exercises/ex02.py: -------------------------------------------------------------------------------- 1 | def prime_checker(number): 2 | divisors = 0 3 | for div in range(1, number + 1): 4 | if number % div == 0: 5 | divisors += 1 6 | 7 | if divisors == 2: 8 | print("It's a prime number.") 9 | else: 10 | print("It's not a prime number.") 11 | 12 | 13 | n = int(input("Check this number: ")) 14 | prime_checker(number=n) 15 | -------------------------------------------------------------------------------- /Day008/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | def greet(): 2 | print("Hello") 3 | print("How do you do?") 4 | print("Isn't the weather nice today?") 5 | 6 | 7 | greet() 8 | print() 9 | 10 | 11 | def greet(): 12 | print("Hello Angela") 13 | print("How do you do Jack Bauer?") 14 | print("Isn't the weather nice today?") 15 | 16 | 17 | greet() 18 | print() 19 | 20 | 21 | def greet_with_name(name): 22 | print(f"Hello {name}") 23 | print(f"How do you do {name}?") 24 | 25 | 26 | greet_with_name("Angela") 27 | greet_with_name("Billie") 28 | -------------------------------------------------------------------------------- /Day008/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | def greet_with(name, location): 2 | print(f'Hello {name}') 3 | print(f'WHat is it like in {location}?') 4 | 5 | 6 | greet_with("Jack Bauer", "Nowhere") 7 | greet_with("Nowhere", "Jack Bauer") 8 | print() 9 | 10 | greet_with(name="Angela", location="London") 11 | greet_with(location="London", name="Angela") 12 | -------------------------------------------------------------------------------- /Day008/Project/caesar_cipher_art.py: -------------------------------------------------------------------------------- 1 | logo = """ 2 | ,adPPYba, ,adPPYYba, ,adPPYba, ,adPPYba, ,adPPYYba, 8b,dPPYba, 3 | a8" "" "" `Y8 a8P_____88 I8[ "" "" `Y8 88P' "Y8 4 | 8b ,adPPPPP88 8PP""""""" `"Y8ba, ,adPPPPP88 88 5 | "8a, ,aa 88, ,88 "8b, ,aa aa ]8I 88, ,88 88 6 | `"Ybbd8"' `"8bbdP"Y8 `"Ybbd8"' `"YbbdP"' `"8bbdP"Y8 88 7 | 88 88 8 | "" 88 9 | 88 10 | ,adPPYba, 88 8b,dPPYba, 88,dPPYba, ,adPPYba, 8b,dPPYba, 11 | a8" "" 88 88P' "8a 88P' "8a a8P_____88 88P' "Y8 12 | 8b 88 88 d8 88 88 8PP""""""" 88 13 | "8a, ,aa 88 88b, ,a8" 88 88 "8b, ,aa 88 14 | `"Ybbd8"' 88 88`YbbdP"' 88 88 `"Ybbd8"' 88 15 | 88 16 | 88 17 | """ 18 | -------------------------------------------------------------------------------- /Day008/Project/project.py: -------------------------------------------------------------------------------- 1 | from caesar_cipher_art import logo 2 | 3 | alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 4 | 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] 5 | 6 | 7 | def caesar(start_text, shift_amount, cipher_direction): 8 | if cipher_direction == 'decode': 9 | shift_amount *= -1 10 | end_text = '' 11 | for char in start_text: 12 | if char in alphabet: 13 | index = (alphabet.index(char) - shift_amount) % len(alphabet) 14 | end_text += alphabet[index] 15 | else: 16 | end_text += char 17 | print(f'The {cipher_direction}d text is: {end_text}') 18 | 19 | 20 | def caesar_cipher(): 21 | print("Type 'encode' to encrypt, type 'decode' to decrypt:") 22 | direction = input() 23 | print("Type your message:") 24 | text = input().lower() 25 | print("Type the shift number:") 26 | shift = int(input()) 27 | caesar(text, shift, direction) 28 | 29 | 30 | print(logo) 31 | 32 | restart = 'yes' 33 | 34 | while restart == 'yes': 35 | caesar_cipher() 36 | restart = input('Do you wish to continue? "yes" or "no": ').lower() 37 | print("Goodbye!!!") 38 | -------------------------------------------------------------------------------- /Day008/Project/project01.py: -------------------------------------------------------------------------------- 1 | alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 2 | 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] 3 | 4 | 5 | def encrypt(plain_text, shift_amount): 6 | encrypt_text = '' 7 | for letter in plain_text: 8 | index = (alphabet.index(letter) + shift_amount) % len(alphabet) 9 | encrypt_text += alphabet[index] 10 | print(f'The encoded text is: {encrypt_text}') 11 | 12 | 13 | print("Type 'encode' to encrypt, type 'decode' to decrypt:") 14 | direction = input() 15 | print("Type your message:") 16 | text = input().lower() 17 | print("Type the shift number:") 18 | shift = int(input()) 19 | 20 | if direction == 'encode': 21 | encrypt(text, shift) 22 | 23 | 24 | -------------------------------------------------------------------------------- /Day008/Project/project02.py: -------------------------------------------------------------------------------- 1 | alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 2 | 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] 3 | 4 | 5 | def encrypt(plain_text, shift_amount): 6 | encrypt_text = '' 7 | for letter in plain_text: 8 | index = (alphabet.index(letter) + shift_amount) % len(alphabet) 9 | encrypt_text += alphabet[index] 10 | print(f'The encoded text is: {encrypt_text}') 11 | 12 | 13 | def decrypt(encrypt_text, shift_amount): 14 | plain_text = '' 15 | for letter in encrypt_text: 16 | index = (alphabet.index(letter) - shift_amount) % len(alphabet) 17 | plain_text += alphabet[index] 18 | print(f'The decoded text is: {plain_text}') 19 | 20 | 21 | print("Type 'encode' to encrypt, type 'decode' to decrypt:") 22 | direction = input() 23 | print("Type your message:") 24 | text = input().lower() 25 | print("Type the shift number:") 26 | shift = int(input()) 27 | 28 | if direction == 'encode': 29 | encrypt(text, shift) 30 | elif direction == 'decode': 31 | decrypt(text, shift) 32 | else: 33 | print('Invalid command') 34 | 35 | 36 | -------------------------------------------------------------------------------- /Day008/Project/project03.py: -------------------------------------------------------------------------------- 1 | alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 2 | 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] 3 | 4 | 5 | def caesar(start_text, shift_amount, cipher_direction): 6 | if cipher_direction == 'decode': 7 | shift_amount *= -1 8 | end_text = '' 9 | for letter in start_text: 10 | index = (alphabet.index(letter) - shift_amount) % len(alphabet) 11 | end_text += alphabet[index] 12 | print(f'The {cipher_direction}d text is: {end_text}') 13 | 14 | 15 | print("Type 'encode' to encrypt, type 'decode' to decrypt:") 16 | direction = input() 17 | print("Type your message:") 18 | text = input().lower() 19 | print("Type the shift number:") 20 | shift = int(input()) 21 | 22 | caesar(text, shift, direction) 23 | -------------------------------------------------------------------------------- /Day009/Exercises/ex01.py: -------------------------------------------------------------------------------- 1 | student_scores = { 2 | "Harry": 81, 3 | "Ron": 78, 4 | "Hermione": 99, 5 | "Draco": 74, 6 | "Neville": 62, 7 | } 8 | 9 | student_grades = {} 10 | for student in student_scores: 11 | score = student_scores[student] 12 | if score > 90: 13 | student_grades[student] = 'Outstanding' 14 | elif score > 80: 15 | student_grades[student] = 'Exceeds Expectations' 16 | elif score > 70: 17 | student_grades[student] = 'Acceptable' 18 | else: 19 | student_grades[student] = 'Fail' 20 | 21 | print(student_grades) 22 | -------------------------------------------------------------------------------- /Day009/Exercises/ex02.py: -------------------------------------------------------------------------------- 1 | travel_log = [ 2 | { 3 | "country": "France", 4 | "visits": 12, 5 | "cities": ["Paris", "Lille", "Dijon"] 6 | }, 7 | { 8 | "country": "Germany", 9 | "visits": 5, 10 | "cities": ["Berlin", "Hamburg", "Stuttgart"] 11 | }, 12 | ] 13 | 14 | 15 | def add_new_country(country, visits, cities): 16 | new_country = { 17 | "country": country, 18 | "visits": visits, 19 | "cities": cities 20 | } 21 | travel_log.append(new_country) 22 | 23 | 24 | add_new_country("Russia", 2, ["Moscow", "Saint Petersburg"]) 25 | print(travel_log) 26 | -------------------------------------------------------------------------------- /Day009/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | programming_dictionary = { 2 | "Bug": "An error in a program that prevents the program from running as expected.", 3 | "Function": "A piece of code that you can easily call over and over again." 4 | } 5 | 6 | print(programming_dictionary["Bug"]) 7 | # print(programming_dictionary["Bog"]) # KeyError 8 | print(programming_dictionary["Function"]) 9 | print() 10 | 11 | print(programming_dictionary) 12 | programming_dictionary["Loop"] = "The action of doing something over and over again." 13 | print(programming_dictionary) 14 | print() 15 | 16 | empty_dictionary = {} 17 | print(empty_dictionary) 18 | print() 19 | 20 | programming_dictionary = {} 21 | print(programming_dictionary) 22 | print() 23 | 24 | programming_dictionary = { 25 | "Bug": "A moth in your computer", 26 | "Function": "A piece of code that you can easily call over and over again.", 27 | "Loop": "The action of doing something over and over again." 28 | } 29 | print(programming_dictionary) 30 | print() 31 | 32 | for key in programming_dictionary: 33 | print(f'{key}: {programming_dictionary[key]}') 34 | -------------------------------------------------------------------------------- /Day009/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | capitals = { 2 | "France": "Paris", 3 | "Germany": "Berlin" 4 | } 5 | print(capitals) 6 | print() 7 | 8 | travel_log = { 9 | "France": ["Paris", "Lille", "Dijon"], 10 | "Germany": ["Berlin", "Hamburg", "Stuttgart"] 11 | } 12 | print(travel_log) 13 | print() 14 | 15 | travel_log = { 16 | "France": { 17 | "cities visited": ["Paris", "Lille", "Dijon"], 18 | "total visits": 12 19 | }, 20 | "Germany": { 21 | "cities visited": ["Berlin", "Hamburg", "Stuttgart"], 22 | "total visits": 5 23 | } 24 | } 25 | print(travel_log) 26 | print() 27 | 28 | travel_log = [ 29 | { 30 | "country": "France", 31 | "cities visited": ["Paris", "Lille", "Dijon"], 32 | "total visits": 12 33 | }, 34 | { 35 | "country": "Germany", 36 | "cities visited": ["Berlin", "Hamburg", "Stuttgart"], 37 | "total visits": 5 38 | } 39 | ] 40 | 41 | print(travel_log) 42 | -------------------------------------------------------------------------------- /Day009/Project/auction_art.py: -------------------------------------------------------------------------------- 1 | logo = r''' 2 | ___________ 3 | \ / 4 | )_______( 5 | |"""""""|_.-._,.---------.,_.-._ 6 | | | | | | | ''-. 7 | | |_| |_ _| |_..-' 8 | |_______| '-' `'---------'` '-' 9 | )"""""""( 10 | /_________\\ 11 | .-------------. 12 | /_______________\\ 13 | ''' 14 | -------------------------------------------------------------------------------- /Day009/Project/flowchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day009/Project/flowchart.png -------------------------------------------------------------------------------- /Day009/Project/project.py: -------------------------------------------------------------------------------- 1 | import os 2 | import auction_art 3 | 4 | 5 | def clear_screen(): 6 | os.system("cls" if os.name == 'nt' else 'clear') 7 | 8 | 9 | bid_dict = {} 10 | another = 'yes' 11 | while another == 'yes': 12 | print(auction_art.logo) 13 | name = input('What is your name? ') 14 | bid = float(input('What is your bid? $')) 15 | print("Are there any other bidders? Type 'yes' or 'no'.") 16 | another = input() 17 | bid_dict[name] = bid 18 | clear_screen() 19 | 20 | reverse_bid_dict = {} 21 | for name in bid_dict: 22 | bid = bid_dict[name] 23 | reverse_bid_dict[bid] = name 24 | 25 | highest_bid = max(reverse_bid_dict) 26 | print(f'The highest bid is ${highest_bid:.2f} and it was made by {reverse_bid_dict[highest_bid]}') 27 | -------------------------------------------------------------------------------- /Day010/Code_Along/calc01.py: -------------------------------------------------------------------------------- 1 | def add(a, b): 2 | return a + b 3 | 4 | 5 | def subtract(a, b): 6 | return a - b 7 | 8 | 9 | def multiply(a, b): 10 | return a * b 11 | 12 | 13 | def divide(a, b): 14 | return a / b 15 | 16 | 17 | operations = { 18 | '+': add, 19 | '-': subtract, 20 | '*': multiply, 21 | '/': divide 22 | } 23 | 24 | 25 | num1 = int(input("What's the first number? ")) 26 | for symbol in operations: 27 | print(symbol, end=' ') 28 | print() 29 | operation = input("Pick an operation from the line above: ") 30 | num2 = int(input("What's the second number? ")) 31 | 32 | calc_func = operations[operation] 33 | answer = calc_func(num1, num2) 34 | print(f"{num1} {operation} {num2} = {answer}") 35 | -------------------------------------------------------------------------------- /Day010/Code_Along/calc02.py: -------------------------------------------------------------------------------- 1 | def add(a, b): 2 | return a + b 3 | 4 | 5 | def subtract(a, b): 6 | return a - b 7 | 8 | 9 | def multiply(a, b): 10 | return a * b 11 | 12 | 13 | def divide(a, b): 14 | return a / b 15 | 16 | 17 | operations = { 18 | '+': add, 19 | '-': subtract, 20 | '*': multiply, 21 | '/': divide 22 | } 23 | 24 | num1 = int(input("What's the first number? ")) 25 | for symbol in operations: 26 | print(symbol, end=' ') 27 | print() 28 | operation = input("Pick an operation from the line above: ") 29 | num2 = int(input("What's the second number? ")) 30 | 31 | calc_func = operations[operation] 32 | first_answer = calc_func(num1, num2) 33 | print(f"{num1} {operation} {num2} = {first_answer}") 34 | 35 | operation = input("Pick another operation: ") 36 | num3 = int(input("What's the next number? ")) 37 | calc_func = operations[operation] 38 | # second_answer = calc_func(calc_func(num1, num2), num3) 39 | second_answer = calc_func(first_answer, num3) 40 | print(f"{first_answer} {operation} {num2} = {second_answer}") 41 | 42 | -------------------------------------------------------------------------------- /Day010/Code_Along/calc03.py: -------------------------------------------------------------------------------- 1 | def add(a, b): 2 | return a + b 3 | 4 | 5 | def subtract(a, b): 6 | return a - b 7 | 8 | 9 | def multiply(a, b): 10 | return a * b 11 | 12 | 13 | def divide(a, b): 14 | return a / b 15 | 16 | 17 | operations = { 18 | '+': add, 19 | '-': subtract, 20 | '*': multiply, 21 | '/': divide 22 | } 23 | 24 | 25 | def calculator(): 26 | num1 = int(input("What's the first number? ")) 27 | user_choice = 'y' 28 | while user_choice == 'y': 29 | for symbol in operations: 30 | print(symbol, end=' ') 31 | print() 32 | operation = input("Pick an operation: ") 33 | num2 = int(input("What's the next number? ")) 34 | calc_func = operations[operation] 35 | result = calc_func(num1, num2) 36 | print(f"{num1} {operation} {num2} = {result}") 37 | print(f"Type 'y' to continue calculating with {result},") 38 | print(f"'n' to start a new calculation: ") 39 | user_choice = input() 40 | if user_choice == 'n': 41 | calculator() 42 | num1 = result 43 | 44 | 45 | calculator() 46 | -------------------------------------------------------------------------------- /Day010/Exercises/ex.py: -------------------------------------------------------------------------------- 1 | def is_leap(y): 2 | return y % 400 == 0 or y % 4 == 0 and y % 100 != 0 3 | 4 | 5 | def days_in_month(y, m): 6 | month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] 7 | if m == 2 and is_leap(y): 8 | return 29 9 | return month_days[m - 1] 10 | 11 | 12 | # 🚨 Do NOT change any of the code below 13 | year = int(input("Enter a year: ")) 14 | month = int(input("Enter a month: ")) 15 | days = days_in_month(year, month) 16 | print(days) 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Day010/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | def format_name(first_name, last_name): 2 | formatted_first_name = first_name.title() 3 | formatted_last_name = last_name.title() 4 | return f"{formatted_first_name} {formatted_last_name}" 5 | 6 | 7 | print(format_name("AnGeLa", "YU")) 8 | 9 | output = len("Angela") 10 | print(output) 11 | -------------------------------------------------------------------------------- /Day010/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | def format_name(first_name, last_name): 2 | if first_name == "" or last_name == "": 3 | return "You didn't provide valid inputs." 4 | formatted_first_name = first_name.title() 5 | formatted_last_name = last_name.title() 6 | return f"Result: {formatted_first_name} {formatted_last_name}" 7 | 8 | 9 | print(format_name(input("What is your first name? "), 10 | input("What is your last name? "))) 11 | 12 | -------------------------------------------------------------------------------- /Day010/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | def format_name(first_name, last_name): 2 | """Take a first and last name and format it 3 | to return the title case version of the name.""" 4 | if first_name == "" or last_name == "": 5 | return "You didn't provide valid inputs." 6 | formatted_first_name = first_name.title() 7 | formatted_last_name = last_name.title() 8 | return f"Result: {formatted_first_name} {formatted_last_name}" 9 | 10 | 11 | print(format_name(input("What is your first name? "), 12 | input("What is your last name? "))) 13 | -------------------------------------------------------------------------------- /Day010/Project/project.md: -------------------------------------------------------------------------------- 1 | # Calculator 2 | 3 | # Instructions 4 | This project was done as a code along so for the previous steps of the project please check the Code_Along folder. 5 | 6 | 7 | 1. Add the logo from [calc_art.py](calc_art.py) 8 | 2. Fix bugs that happens with floating-point numbers. 9 | 10 | -------------------------------------------------------------------------------- /Day010/Project/project.py: -------------------------------------------------------------------------------- 1 | import calc_art 2 | 3 | 4 | def add(a, b): 5 | return a + b 6 | 7 | 8 | def subtract(a, b): 9 | return a - b 10 | 11 | 12 | def multiply(a, b): 13 | return a * b 14 | 15 | 16 | def divide(a, b): 17 | return a / b 18 | 19 | 20 | operations = { 21 | '+': add, 22 | '-': subtract, 23 | '*': multiply, 24 | '/': divide 25 | } 26 | 27 | 28 | def calculator(): 29 | num1 = float(input("What's the first number? ")) 30 | user_choice = 'y' 31 | while user_choice == 'y': 32 | for symbol in operations: 33 | print(symbol, end=' ') 34 | print() 35 | operation = input("Pick an operation: ") 36 | num2 = float(input("What's the next number? ")) 37 | calc_func = operations[operation] 38 | result = calc_func(num1, num2) 39 | print(f"{num1} {operation} {num2} = {result}") 40 | print(f"Type 'y' to continue calculating with {result},") 41 | print(f"'n' to start a new calculation: ") 42 | user_choice = input() 43 | if user_choice == 'n': 44 | calculator() 45 | num1 = result 46 | 47 | 48 | print(calc_art.logo) 49 | calculator() 50 | -------------------------------------------------------------------------------- /Day011/Capstone_Project/blackjack_art.py: -------------------------------------------------------------------------------- 1 | logo = r""" 2 | .------. _ _ _ _ _ 3 | |A_ _ |. | | | | | | (_) | | 4 | |( \/ ).-----. | |__ | | __ _ ___| | ___ __ _ ___| | __ 5 | | \ /|K /\ | | '_ \| |/ _` |/ __| |/ / |/ _` |/ __| |/ / 6 | | \/ | / \ | | |_) | | (_| | (__| <| | (_| | (__| < 7 | `-----| \ / | |_.__/|_|\__,_|\___|_|\_\ |\__,_|\___|_|\_\\ 8 | | \/ K| _/ | 9 | `------' |__/ 10 | """ 11 | 12 | deck = [] 13 | 14 | 15 | -------------------------------------------------------------------------------- /Day012/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | enemies = 1 2 | 3 | 4 | def increase_enemies(): 5 | enemies = 2 6 | print(f"enemies inside function: {enemies}") 7 | 8 | 9 | increase_enemies() 10 | print(f"enemies outside function: {enemies}") 11 | -------------------------------------------------------------------------------- /Day012/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | player_health = 10 2 | 3 | 4 | def drink_potion(): 5 | potion_strength = 2 6 | print(f'potion_strength = {potion_strength}') 7 | print(f'player_health = {player_health}') 8 | 9 | 10 | drink_potion() 11 | # print(potion_strength) # NameError 12 | 13 | -------------------------------------------------------------------------------- /Day012/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | player_health = 10 2 | 3 | 4 | def game(): 5 | def drink_potion(): 6 | potion_strength = 2 7 | print(f'potion_strength = {potion_strength}') 8 | print(f'player_health = {player_health}') 9 | 10 | drink_potion() 11 | 12 | 13 | # drink_potion() # NameError 14 | game() 15 | print(player_health) 16 | -------------------------------------------------------------------------------- /Day012/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | def create_enemy(): 2 | game_level = 3 3 | enemies = ["Skeleton", "Zombie", "Alien"] 4 | if game_level < 5: 5 | new_enemy = enemies[0] 6 | print(new_enemy) 7 | 8 | 9 | create_enemy() 10 | # print(new_enemy) # NameError 11 | -------------------------------------------------------------------------------- /Day012/Lectures/lec05.py: -------------------------------------------------------------------------------- 1 | enemies = 1 2 | 3 | 4 | def increase_enemies(): 5 | global enemies 6 | enemies += 1 7 | print(f"enemies inside function: {enemies}") 8 | 9 | 10 | increase_enemies() 11 | print(f"enemies outside function: {enemies}") 12 | -------------------------------------------------------------------------------- /Day012/Lectures/lec06.py: -------------------------------------------------------------------------------- 1 | enemies = 1 2 | 3 | 4 | def increase_enemies(): 5 | print(f"enemies inside function: {enemies}") 6 | return enemies + 1 7 | 8 | 9 | enemies = increase_enemies() 10 | print(f"enemies outside function: {enemies}") 11 | -------------------------------------------------------------------------------- /Day012/Lectures/lec07.py: -------------------------------------------------------------------------------- 1 | PI = 3.14159 2 | URL = "https://google.com" 3 | TWITTER_HANDLE = "@yu_angela" 4 | -------------------------------------------------------------------------------- /Day012/Project/game_art.py: -------------------------------------------------------------------------------- 1 | logo = r""" 2 | _ _ _ _____ _ _____ 3 | | \ | | | | / ____| (_) / ____| 4 | | \| |_ _ _ __ ___ | |__ ___ _ __ | | __ ___ ___ ___ _ _ __ __ _ | | __ __ _ _ __ ___ ___ 5 | | . ` | | | | '_ ` _ \| '_ \ / _ \ '__| | | |_ |/ _ \/ __/ __| | '_ \ / _` | | | |_ |/ _` | '_ ` _ \ / _ \ 6 | | |\ | |_| | | | | | | |_) | __/ | | |__| | __/\__ \__ \ | | | | (_| | | |__| | (_| | | | | | | __/ 7 | |_| \_|\__,_|_| |_| |_|_.__/ \___|_| \_____|\___||___/___/_|_| |_|\__, | \_____|\__,_|_| |_| |_|\___| 8 | __/ | 9 | |___/ 10 | """ 11 | -------------------------------------------------------------------------------- /Day012/Project/project.py: -------------------------------------------------------------------------------- 1 | import random 2 | import game_art 3 | 4 | 5 | def eval_guess(secret, guess): 6 | if guess == secret: 7 | print(f'You got it! The answer was {secret}') 8 | return True 9 | if guess > secret: 10 | print('Too high.') 11 | else: 12 | print('Too low.') 13 | return False 14 | 15 | 16 | def guessing_game(secret, attempts): 17 | for _ in range(attempts): 18 | print(f'You have {attempts} attempts remaining to guess the number.') 19 | guess = int(input('Make a guess: ')) 20 | is_guess_correct = eval_guess(secret, guess) 21 | if is_guess_correct: 22 | return 23 | attempts -= 1 24 | print("You've run out of guesses, you lose.") 25 | 26 | 27 | def play_game(): 28 | print(game_art.logo) 29 | secret = random.randint(1, 100) 30 | difficulty = input("Choose a difficulty. Type 'easy' or 'hard': ") 31 | if difficulty == 'easy': 32 | attempts = 10 33 | elif difficulty == 'hard': 34 | attempts = 5 35 | else: 36 | print(f'"{difficulty}" is not an option.') 37 | print("Please rerun the program and type a VALID option.") 38 | return 39 | guessing_game(secret, attempts) 40 | 41 | 42 | play_game() 43 | -------------------------------------------------------------------------------- /Day013/Exercises/ex01.md: -------------------------------------------------------------------------------- 1 | ## Debug Odd or Even 2 | 3 | # Instructions 4 | 5 | - Read this the code in [ex01.py](ex01.py) 6 | - Spot the problems. 7 | - Modify the code to fix the program. 8 | 9 | Fix the code so that it works and passes the tests when you submit. 10 | 11 | # Code with Bug 12 | 13 | ```python 14 | number = int(input("Which number do you want to check?")) 15 | 16 | if number % 2 = 0: 17 | print("This is an even number.") 18 | else: 19 | print("This is an odd number.") 20 | 21 | 22 | ``` 23 | 24 | # Hint 25 | 26 | 1. Review the previous lesson and go through the 10 steps to tackle these debugging problems. 27 | 28 | # Solution 29 | 30 | [https://repl.it/@appbrewery/day-13-1-solution](https://repl.it/@appbrewery/day-13-1-solution) 31 | -------------------------------------------------------------------------------- /Day013/Exercises/ex01.py: -------------------------------------------------------------------------------- 1 | number = int(input("Which number do you want to check? ")) 2 | 3 | if number % 2 == 0: 4 | print("This is an even number.") 5 | else: 6 | print("This is an odd number.") 7 | 8 | -------------------------------------------------------------------------------- /Day013/Exercises/ex02.md: -------------------------------------------------------------------------------- 1 | ## Debug Leap Year 2 | 3 | # Instructions 4 | 5 | - Read this the code in [ex02.py](ex02.py) 6 | - Spot the problems. 7 | - Modify the code to fix the program. 8 | - No shortcuts - don't copy-paste to replace the code entirely with a working solution. 9 | 10 | Fix the code so that it works and when you hit submit it should pass all the tests. 11 | 12 | # Code with Bug 13 | 14 | ```python 15 | year = input("Which year do you want to check?") 16 | 17 | if year % 4 == 0: 18 | if year % 100 == 0: 19 | if year % 400 == 0: 20 | print("Leap year.") 21 | else: 22 | print("Not leap year.") 23 | else: 24 | print("Leap year.") 25 | else: 26 | print("Not leap year.") 27 | ``` 28 | # Solution 29 | 30 | [https://repl.it/@appbrewery/day-13-2-solution](https://repl.it/@appbrewery/day-13-2-solution) 31 | 32 | -------------------------------------------------------------------------------- /Day013/Exercises/ex02.py: -------------------------------------------------------------------------------- 1 | year = int(input("Which year do you want to check? ")) 2 | 3 | if year % 4 == 0: 4 | if year % 100 == 0: 5 | if year % 400 == 0: 6 | print("Leap year.") 7 | else: 8 | print("Not leap year.") 9 | else: 10 | print("Leap year.") 11 | else: 12 | print("Not leap year.") 13 | -------------------------------------------------------------------------------- /Day013/Exercises/ex03.py: -------------------------------------------------------------------------------- 1 | for number in range(1, 101): 2 | if number % 3 == 0 and number % 5 == 0: 3 | print("FizzBuzz") 4 | elif number % 3 == 0: 5 | print("Fizz") 6 | elif number % 5 == 0: 7 | print("Buzz") 8 | else: 9 | print(number) 10 | -------------------------------------------------------------------------------- /Day013/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | # Describe Problem: 2 | # The problem is that the function won't do anything 3 | # since 'i' will never have a value of 20 in the loop. 4 | 5 | # def my_function(): 6 | # for i in range(1, 20): 7 | # if i == 20: 8 | # print("You got it") 9 | # my_function() 10 | 11 | def my_function(): 12 | for i in range(1, 21): 13 | if i == 20: 14 | print("You got it") 15 | 16 | 17 | my_function() 18 | -------------------------------------------------------------------------------- /Day013/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | # Reproduce the Bug: 2 | # 2 bugs will happen because of a off by one error 3 | # dice_num will never have a value of 0 and when it 4 | # has a value of 6 dice_imgs[dice_num] will cause 5 | # a IndexError 6 | 7 | # from random import randint 8 | # 9 | # dice_imgs = ["❶", "❷", "❸", "❹", "❺", "❻"] 10 | # dice_num = randint(1, 6) 11 | # print(dice_imgs[dice_num]) 12 | 13 | # from random import randint 14 | # 15 | # dice_imgs = ["❶", "❷", "❸", "❹", "❺", "❻"] 16 | # dice_num = randint(1, 6) 17 | # print(dice_imgs[6]) # IndexError 18 | 19 | from random import randint 20 | 21 | dice_imgs = ["❶", "❷", "❸", "❹", "❺", "❻"] 22 | dice_num = randint(0, 5) 23 | print(dice_imgs[dice_num]) 24 | -------------------------------------------------------------------------------- /Day013/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | # Play Computer 2 | 3 | # year = int(input("What's your year of birth?")) 4 | # if year > 1980 and year < 1994: 5 | # print("You are a millennial.") 6 | # elif year > 1994: 7 | # print("You are a Gen Z.") 8 | year = int(input("What's your year of birth? ")) 9 | if year > 1980 and year <= 1994: 10 | print("You are a millennial.") 11 | elif year > 1994: 12 | print("You are a Gen Z.") 13 | -------------------------------------------------------------------------------- /Day013/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | # Fix the Errors 2 | 3 | # age = input("How old are you?") 4 | # if age > 18: 5 | # print("You can drive at age {age}.") 6 | age = int(input("How old are you? ")) 7 | if age > 18: 8 | print(f"You can drive at age {age}.") 9 | -------------------------------------------------------------------------------- /Day013/Lectures/lec05.py: -------------------------------------------------------------------------------- 1 | # Print is Your Friend 2 | 3 | # pages = 0 4 | # word_per_page = 0 5 | # pages = int(input("Number of pages: ")) 6 | # word_per_page == int(input("Number of words per page: ")) 7 | # total_words = pages * word_per_page 8 | # print(total_words) 9 | 10 | # pages = 0 11 | # word_per_page = 0 12 | # pages = int(input("Number of pages: ")) 13 | # word_per_page == int(input("Number of words per page: ")) 14 | # total_words = pages * word_per_page 15 | # print(total_words) 16 | # print(f'pages is {pages}') 17 | # print(f'word_per_page is {word_per_page}') 18 | 19 | pages = int(input("Number of pages: ")) 20 | word_per_page = int(input("Number of words per page: ")) 21 | total_words = pages * word_per_page 22 | print(total_words) 23 | -------------------------------------------------------------------------------- /Day013/Lectures/lec06.py: -------------------------------------------------------------------------------- 1 | # Use a Debugger 2 | 3 | # def mutate(a_list): 4 | # b_list = [] 5 | # for item in a_list: 6 | # new_item = item * 2 7 | # b_list.append(new_item) 8 | # print(b_list) 9 | 10 | # mutate([1,2,3,5,8,13]) 11 | 12 | def mutate(a_list): 13 | b_list = [] 14 | for item in a_list: 15 | new_item = item * 2 16 | b_list.append(new_item) 17 | print(b_list) 18 | 19 | mutate([1,2,3,5,8,13]) 20 | -------------------------------------------------------------------------------- /Day014/Project/game_art.py: -------------------------------------------------------------------------------- 1 | logo = r""" 2 | __ __ __ _______ __ __ _______ .______ 3 | | | | | | | / _____|| | | | | ____|| _ \ 4 | | |__| | | | | | __ | |__| | | |__ | |_) | 5 | | __ | | | | | |_ | | __ | | __| | / 6 | | | | | | | | |__| | | | | | | |____ | |\ \----. 7 | |__| |__| |__| \______| |__| |__| |_______|| _| `._____| 8 | __ ______ ____ __ ____ _______ .______ 9 | | | / __ \ \ \ / \ / / | ____|| _ \ 10 | | | | | | | \ \/ \/ / | |__ | |_) | 11 | | | | | | | \ / | __| | / 12 | | `----.| `--' | \ /\ / | |____ | |\ \----. 13 | |_______| \______/ \__/ \__/ |_______|| _| `._____|""" 14 | 15 | 16 | vs = r""" 17 | ____ ____ _______. 18 | \ \ / / / | 19 | \ \/ / | (----` 20 | \ / \ \ 21 | \ / .----) |__ 22 | \__/ |_______/(__)""" 23 | -------------------------------------------------------------------------------- /Day015/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | print("Hello world!") 2 | -------------------------------------------------------------------------------- /Day015/Project/coffee_machine_data.py: -------------------------------------------------------------------------------- 1 | MENU = { 2 | "espresso": { 3 | "ingredients": { 4 | "water": 50, 5 | "milk": 0, 6 | "coffee": 18, 7 | }, 8 | "cost": 1.5, 9 | }, 10 | "latte": { 11 | "ingredients": { 12 | "water": 200, 13 | "milk": 150, 14 | "coffee": 24, 15 | }, 16 | "cost": 2.5, 17 | }, 18 | "cappuccino": { 19 | "ingredients": { 20 | "water": 250, 21 | "milk": 100, 22 | "coffee": 24, 23 | }, 24 | "cost": 3.0, 25 | } 26 | } 27 | 28 | resources = { 29 | "water": 300, 30 | "milk": 200, 31 | "coffee": 100, 32 | "money": 0 33 | } 34 | -------------------------------------------------------------------------------- /Day015/Project/project.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day015/Project/project.pdf -------------------------------------------------------------------------------- /Day016/Lecture/lec01.py: -------------------------------------------------------------------------------- 1 | import module 2 | print(module.variable) 3 | -------------------------------------------------------------------------------- /Day016/Lecture/lec02.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle, Screen 2 | 3 | timmy = Turtle() 4 | print(timmy) 5 | timmy.shape('turtle') 6 | timmy.color('coral') 7 | 8 | timmy.forward(100) 9 | 10 | my_screen = Screen() 11 | print(my_screen.canvheight) 12 | my_screen.exitonclick() 13 | -------------------------------------------------------------------------------- /Day016/Lecture/lec03.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day016/Lecture/lec03.py -------------------------------------------------------------------------------- /Day016/Lecture/lec04.py: -------------------------------------------------------------------------------- 1 | from prettytable import PrettyTable 2 | 3 | table = PrettyTable() 4 | 5 | table.add_column('Pokemon Name', ['Pikachu', 'Squirtle', 'Charmander']) 6 | table.add_column('Type', ['Electric', 'Water', 'Fire']) 7 | print(table) 8 | print() 9 | 10 | table.align = 'l' 11 | print(table) 12 | -------------------------------------------------------------------------------- /Day016/Lecture/module.py: -------------------------------------------------------------------------------- 1 | variable = 12 2 | -------------------------------------------------------------------------------- /Day016/Project/coffee_maker.py: -------------------------------------------------------------------------------- 1 | class CoffeeMaker: 2 | """Models the machine that makes the coffee""" 3 | def __init__(self): 4 | self.resources = { 5 | "water": 300, 6 | "milk": 200, 7 | "coffee": 100, 8 | } 9 | 10 | def report(self): 11 | """Prints a report of all resources.""" 12 | print(f"Water: {self.resources['water']}ml") 13 | print(f"Milk: {self.resources['milk']}ml") 14 | print(f"Coffee: {self.resources['coffee']}g") 15 | 16 | def is_resource_sufficient(self, drink): 17 | """Returns True when order can be made, False if ingredients are insufficient.""" 18 | can_make = True 19 | for item in drink.ingredients: 20 | if drink.ingredients[item] > self.resources[item]: 21 | print(f"Sorry there is not enough {item}.") 22 | can_make = False 23 | return can_make 24 | 25 | def make_coffee(self, order): 26 | """Deducts the required ingredients from the resources.""" 27 | for item in order.ingredients: 28 | self.resources[item] -= order.ingredients[item] 29 | print(f"Here is your {order.name} ☕️. Enjoy!") 30 | -------------------------------------------------------------------------------- /Day016/Project/project.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day016/Project/project.pdf -------------------------------------------------------------------------------- /Day016/Project/project.py: -------------------------------------------------------------------------------- 1 | from menu import Menu 2 | from coffee_maker import CoffeeMaker 3 | from money_machine import MoneyMachine 4 | 5 | 6 | def coffee_machine(): 7 | menu = Menu() 8 | coffee_maker = CoffeeMaker() 9 | money_machine = MoneyMachine() 10 | 11 | while True: 12 | options = menu.get_items() 13 | choice = input(f'What would you like? ({options}): ').lower() 14 | if choice == 'off': 15 | return 16 | elif choice == 'report': 17 | coffee_maker.report() 18 | money_machine.report() 19 | else: 20 | coffee = menu.find_drink(choice) 21 | if coffee_maker.is_resource_sufficient(coffee): 22 | if money_machine.make_payment(coffee.cost): 23 | coffee_maker.make_coffee(coffee) 24 | 25 | 26 | coffee_machine() 27 | -------------------------------------------------------------------------------- /Day017/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | class User: 2 | pass 3 | 4 | 5 | user_1 = User() 6 | -------------------------------------------------------------------------------- /Day017/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | class User: 2 | def __init__(self): 3 | print("New user being created...") 4 | 5 | 6 | user_1 = User() 7 | user_1.id = "001" 8 | user_1.username = "angela" 9 | 10 | print(user_1.id) 11 | print(user_1.username) 12 | 13 | user_2 = User() 14 | user_2.id = "002" 15 | user_2.username = "jack" 16 | 17 | print(user_2.id) 18 | print(user_2.username) 19 | 20 | -------------------------------------------------------------------------------- /Day017/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | class User: 2 | def __init__(self, user_id, username): 3 | self.id = user_id 4 | self.username = username 5 | self.followers = 0 6 | 7 | 8 | user_1 = User("001", "angela") 9 | user_2 = User("002", "jack") 10 | 11 | print(user_1.id) 12 | print(user_1.username) 13 | print(user_1.followers) 14 | 15 | print(user_2.id) 16 | print(user_2.username) 17 | print(user_2.followers) 18 | -------------------------------------------------------------------------------- /Day017/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | class User: 2 | def __init__(self, user_id, username): 3 | self.id = user_id 4 | self.username = username 5 | self.followers = 0 6 | self.following = 0 7 | 8 | def follow(self, user): 9 | user.followers += 1 10 | self.following += 1 11 | 12 | 13 | user_1 = User("001", "angela") 14 | user_2 = User("002", "jack") 15 | 16 | user_1.follow(user_2) 17 | print(user_1.followers) 18 | print(user_1.following) 19 | print(user_2.followers) 20 | print(user_2.following) 21 | -------------------------------------------------------------------------------- /Day017/Project/Project01/project.md: -------------------------------------------------------------------------------- 1 | # Quiz 2 | 3 | # Instructions 4 | 5 | - Create a `Question` class in the [question_model.py](question_model.py) with an `__init__()` method with 2 attributes: 6 | - `text` 7 | - `answer` 8 | - Create `question_bank` a list of Question objects with the data from [quiz_data.py](quiz_data.py) in the [project.py](project.py). 9 | - In the [quiz_brain.py](quiz_brain.py) file create a class that: 10 | - Ask the questions 11 | - Check if the answer was correct 12 | - Are you at the end of the quiz? 13 | - Use the classes created to run the quiz with all the questions in [project.py](project.py). 14 | - Use the data from [https://opentdb.com/](https://opentdb.com/) using API. 15 | 16 | -------------------------------------------------------------------------------- /Day017/Project/Project01/project.py: -------------------------------------------------------------------------------- 1 | import random 2 | from question_model import Question 3 | from quiz_brain import QuizBrain 4 | from quiz_data import question_data, question_data_api 5 | 6 | question_bank = [] 7 | 8 | 9 | for question in question_data: 10 | question_bank.append(Question(question['text'], question['answer'])) 11 | 12 | for question in question_data_api: 13 | question_bank.append(Question(question['question'], question['correct_answer'])) 14 | 15 | quiz = QuizBrain(question_bank) 16 | 17 | while quiz.still_has_questions(): 18 | quiz.next_question() 19 | 20 | print("You've completed the quiz!!!") 21 | print(f"Your final score was: {quiz.score}/{len(question_bank)}") 22 | -------------------------------------------------------------------------------- /Day017/Project/Project01/question_model.py: -------------------------------------------------------------------------------- 1 | class Question: 2 | def __init__(self, text, answer): 3 | self.text = text 4 | self.answer = answer 5 | -------------------------------------------------------------------------------- /Day017/Project/Project01/quiz_brain.py: -------------------------------------------------------------------------------- 1 | class QuizBrain: 2 | def __init__(self, question_list): 3 | self.question_number = 0 4 | self.question_list = question_list 5 | self.score = 0 6 | 7 | def still_has_questions(self): 8 | return len(self.question_list) > self.question_number 9 | 10 | def next_question(self): 11 | current_question = self.question_list[self.question_number] 12 | self.question_number += 1 13 | user_answer = input(f'Q.{self.question_number}: {current_question.text}? (True/False): ') 14 | self.check_answer(user_answer, current_question.answer) 15 | 16 | def check_answer(self, user_answer, correct_answer): 17 | if user_answer.lower() == correct_answer.lower(): 18 | print('You got it right!') 19 | self.score += 1 20 | else: 21 | print("That's wrong.") 22 | print(f"The correct answer was: {correct_answer}.") 23 | print(f"Your current score is: {self.score}/{self.question_number}") 24 | print() 25 | -------------------------------------------------------------------------------- /Day018/Challenges/ch.md: -------------------------------------------------------------------------------- 1 | # Turtle Challenges 2 | 3 | ## Challenge 1 4 | 5 | - Draw a square using Turtle in [ch01.py](ch01.py) 6 | 7 | ## Challenge 2 8 | 9 | - Draw a dashed line 10 | 11 | 12 | ## Challenge 3 13 | 14 | - Draw shapes with the following number of sides: 3, 4, 5, 6, 7, 8, 9, 10. 15 | - Make the colors be random 16 | 17 | ## Challenge 4 18 | 19 | - Use the turtle to draw a random walk 20 | 21 | ## Challenge 5 22 | 23 | - Draw 24 | -------------------------------------------------------------------------------- /Day018/Challenges/ch01.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle, Screen 2 | 3 | tim = Turtle() 4 | 5 | for _ in range(4): 6 | tim.pencolor() 7 | tim.fd(100) 8 | tim.left(90) 9 | 10 | screen = Screen() 11 | screen.exitonclick() 12 | -------------------------------------------------------------------------------- /Day018/Challenges/ch02.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle, Screen 2 | 3 | tim = Turtle() 4 | 5 | for _ in range(15): 6 | tim.fd(10) 7 | tim.up() 8 | tim.fd(10) 9 | tim.down() 10 | 11 | screen = Screen() 12 | screen.exitonclick() 13 | -------------------------------------------------------------------------------- /Day018/Challenges/ch03.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle, Screen 2 | from random import shuffle 3 | 4 | 5 | def calc_angle(sides): 6 | return 360 / sides 7 | 8 | 9 | def draw_shape(turtle, length, sides, color): 10 | turtle.color(color) 11 | angle = calc_angle(sides) 12 | for _ in range(sides): 13 | turtle.fd(length) 14 | turtle.right(angle) 15 | 16 | 17 | def set_start_position(turtle, x, y): 18 | turtle.up() 19 | turtle.goto(x, y) 20 | turtle.down() 21 | 22 | 23 | def main(): 24 | tim = Turtle() 25 | tim.pensize(3) 26 | set_start_position(tim, -150, 150) 27 | 28 | colors = ['blue', 'cyan', 'red', 'hot pink', 29 | 'gold', 'coral', 'indigo', 'lime'] 30 | shuffle(colors) 31 | 32 | sides = 3 33 | for color in colors: 34 | draw_shape(tim, 100, sides, color) 35 | sides += 1 36 | 37 | screen = Screen() 38 | screen.exitonclick() 39 | 40 | 41 | main() 42 | -------------------------------------------------------------------------------- /Day018/Challenges/ch04.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle, Screen 2 | from random import shuffle, choice 3 | 4 | tim = Turtle() 5 | tim.pensize(5) 6 | tim.speed(0) 7 | 8 | colors = ['blue', 'cyan', 'red', 'deep pink', 9 | 'gold', 'coral', 'indigo', 'lime'] 10 | 11 | angles = [0, 90, 180, 270] 12 | 13 | for _ in range(25): 14 | shuffle(colors) 15 | for color in colors: 16 | tim.color(color) 17 | tim.forward(25) 18 | tim.setheading(choice(angles)) 19 | 20 | screen = Screen() 21 | screen.exitonclick() 22 | -------------------------------------------------------------------------------- /Day018/Challenges/ch05.py: -------------------------------------------------------------------------------- 1 | import turtle as t 2 | import random 3 | 4 | 5 | def random_color(): 6 | r = random.randint(0, 255) 7 | g = random.randint(0, 255) 8 | b = random.randint(0, 255) 9 | color = (r, g, b) 10 | return color 11 | 12 | 13 | def draw_spirograph(turtle, gap_size): 14 | rounds = 360 // gap_size 15 | for _ in range(rounds): 16 | turtle.color(random_color()) 17 | turtle.circle(100) 18 | turtle.setheading(tim.heading() + gap_size) 19 | 20 | 21 | tim = t.Turtle() 22 | t.colormode(255) 23 | tim.speed(0) 24 | 25 | draw_spirograph(tim, 5) 26 | 27 | 28 | 29 | screen = t.Screen() 30 | screen.exitonclick() 31 | -------------------------------------------------------------------------------- /Day018/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle, Screen 2 | 3 | timmy = Turtle() 4 | timmy.shape('turtle') 5 | timmy.color('red') 6 | timmy.forward(100) 7 | timmy.right(90) 8 | 9 | screen = Screen() 10 | screen.exitonclick() 11 | 12 | 13 | -------------------------------------------------------------------------------- /Day018/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | # import turtle 2 | # 3 | # tim = turtle.Turtle() 4 | 5 | # from turtle import Turtle 6 | # 7 | # tim = Turtle() 8 | # tom = Turtle() 9 | # terry = Turtle() 10 | 11 | # from turtle import * 12 | # from random import * 13 | # 14 | # print(choice([1, 2, 3])) 15 | # forward(100) 16 | 17 | import turtle as t 18 | import heroes 19 | 20 | tim = t.Turtle() 21 | print(heroes.gen()) 22 | 23 | 24 | -------------------------------------------------------------------------------- /Day018/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | my_tuple = (1, 3, 8) 2 | print(my_tuple[0]) 3 | print(my_tuple[1]) 4 | print(my_tuple[2]) 5 | 6 | # my_tuple[2] = 12 # TypeError 7 | print(list(my_tuple)) 8 | -------------------------------------------------------------------------------- /Day018/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | import turtle as t 2 | import random 3 | 4 | tim = t.Turtle() 5 | t.colormode(255) 6 | 7 | 8 | def random_color(): 9 | r = random.randint(0, 255) 10 | g = random.randint(0, 255) 11 | b = random.randint(0, 255) 12 | color = (r, g, b) 13 | return color 14 | 15 | 16 | directions = (0, 90, 180, 270) 17 | tim.pensize(15) 18 | tim.speed(0) 19 | 20 | for _ in range(200): 21 | tim.color(random_color()) 22 | tim.forward(30) 23 | tim.setheading(random.choice(directions)) 24 | 25 | screen = t.Screen() 26 | screen.exitonclick() 27 | -------------------------------------------------------------------------------- /Day018/Project/project.md: -------------------------------------------------------------------------------- 1 | # Dot Painting 2 | 3 | # Instructions 4 | 5 | - Try to create a simulation of Damien Hirst painting using Python. 6 | 7 | - 10 x 10 8 | - Dot size: 20 9 | - Spacing: 50 10 | 11 | -------------------------------------------------------------------------------- /Day018/Project/project.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | import random 3 | 4 | 5 | def random_color(): 6 | r = random.randint(0, 255) 7 | g = random.randint(0, 255) 8 | b = random.randint(0, 255) 9 | color = (r, g, b) 10 | return color 11 | 12 | 13 | tim = turtle.Turtle() 14 | turtle.colormode(255) 15 | tim.speed(0) 16 | tim.penup() 17 | tim.hideturtle() 18 | x = -250 19 | y = 250 20 | tim.goto(x, y) 21 | count = 0 22 | for _ in range(100): 23 | tim.dot(20, random_color()) 24 | tim.forward(50) 25 | count += 1 26 | if count % 10 == 0: 27 | y -= 50 28 | tim.goto(x, y) 29 | 30 | screen = turtle.Screen() 31 | screen.exitonclick() 32 | -------------------------------------------------------------------------------- /Day019/Challenges/ch.md: -------------------------------------------------------------------------------- 1 | # Etch-a-Sketch 2 | 3 | Use turtle to create an etch-a-sketch game. 4 | 5 | - `W`: Forwards 6 | - `S`: Backwards 7 | - `A`: Counter-Clockwise 8 | - `D`: Clockwise 9 | - `C`: Clear drawing 10 | -------------------------------------------------------------------------------- /Day019/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle, Screen 2 | 3 | 4 | tim = Turtle() 5 | screen = Screen() 6 | 7 | 8 | def move_forwards(): 9 | tim.forward(10) 10 | 11 | 12 | screen.listen() 13 | screen.onkey(key='space', fun=move_forwards) 14 | screen.exitonclick() 15 | -------------------------------------------------------------------------------- /Day019/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | def add(n1, n2): 2 | return n1 + n2 3 | 4 | 5 | def subtract(n1, n2): 6 | return n1 - n2 7 | 8 | 9 | def multiply(n1, n2): 10 | return n1 * n2 11 | 12 | 13 | def divide(n1, n2): 14 | return n1 / n2 15 | 16 | 17 | def calculator(n1, n2, func): 18 | return func(n1, n2) 19 | 20 | 21 | result = calculator(2, 3, add) 22 | print(result) 23 | result = calculator(2, 3, multiply) 24 | print(result) 25 | -------------------------------------------------------------------------------- /Day019/Project/project.md: -------------------------------------------------------------------------------- 1 | # Turtle Race 2 | 3 | # Instructions 4 | - Create a race of turtles. 5 | - Ask the user to make a bet. 6 | - Check if the user wins. 7 | - Make the turtle move randomly. 8 | -------------------------------------------------------------------------------- /Day020/Project/project.md: -------------------------------------------------------------------------------- 1 | # Snake Game - Part 1 - 3 2 | 3 | ## Instructions 4 | 5 | ### Part 1 6 | Create a snake body 7 | 8 | ### Part 2 9 | Move the snake 10 | 11 | ### Part 3 12 | Create snake food 13 | 14 | 15 | -------------------------------------------------------------------------------- /Day020/Project/project.py: -------------------------------------------------------------------------------- 1 | from turtle import Screen 2 | from time import sleep 3 | 4 | from snake import Snake 5 | 6 | screen = Screen() 7 | screen.setup(width=600, height=600) 8 | screen.bgcolor('black') 9 | screen.title("Snake Game") 10 | screen.tracer(0) 11 | 12 | snake = Snake() 13 | 14 | screen.listen() 15 | screen.onkey(snake.up, 'Up') 16 | screen.onkey(snake.down, 'Down') 17 | screen.onkey(snake.left, 'Left') 18 | screen.onkey(snake.right, 'Right') 19 | 20 | game_is_on = True 21 | while game_is_on: 22 | screen.update() 23 | sleep(0.1) 24 | snake.move() 25 | 26 | screen.exitonclick() 27 | -------------------------------------------------------------------------------- /Day020/Project/sketch_project.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle, Screen 2 | import time 3 | screen = Screen() 4 | screen.setup(width=600, height=600) 5 | screen.bgcolor('black') 6 | screen.title("Snake Game") 7 | screen.tracer(0) 8 | 9 | snake = [] 10 | body_pos = [(-40, 0), (-20, 0), (0, 0)] 11 | for pos in body_pos: 12 | turtle = Turtle('square') 13 | turtle.penup() 14 | turtle.goto(pos) 15 | turtle.color('white') 16 | snake.append(turtle) 17 | 18 | game_is_on = True 19 | while game_is_on: 20 | screen.update() 21 | time.sleep(0.1) 22 | for idx in range(len(snake) - 1, 0, -1): 23 | x = snake[idx - 1].xcor() 24 | y = snake[idx - 1].ycor() 25 | snake[idx].goto(x, y) 26 | snake[0].forward(20) 27 | 28 | screen.exitonclick() 29 | -------------------------------------------------------------------------------- /Day021/Lecture/lec01.py: -------------------------------------------------------------------------------- 1 | class Animal: 2 | def __init__(self): 3 | self.num_eyes = 2 4 | 5 | def breathe(self): 6 | print('Inhale, exhale...') 7 | 8 | 9 | class Fish(Animal): 10 | def __init__(self): 11 | super().__init__() 12 | 13 | def breathe(self): 14 | super().breathe() 15 | print('...doing this underwater!') 16 | 17 | def swim(self): 18 | print('Moving in water...') 19 | 20 | 21 | nemo = Fish() 22 | nemo.swim() 23 | nemo.breathe() 24 | print(nemo.num_eyes) 25 | -------------------------------------------------------------------------------- /Day021/Lecture/lec02.py: -------------------------------------------------------------------------------- 1 | piano_keys = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] 2 | piano_tuple = ('do', 're', 'mi', 'fa', 'so', 'la', 'ti') 3 | print(piano_keys[2:5]) 4 | print(piano_keys[:5]) 5 | print(piano_keys[2:]) 6 | print(piano_keys[2:5:2]) 7 | print(piano_keys[::2]) 8 | print(piano_keys[::-1]) 9 | print() 10 | 11 | print(piano_tuple[2:5]) 12 | -------------------------------------------------------------------------------- /Day021/Project/food.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | import random 3 | 4 | 5 | class Food(turtle.Turtle): 6 | FOOD_COLORS = ['red', 'orange', 'yellow', 'green', 7 | 'dodger blue', 'indigo', 'violet'] 8 | 9 | def __init__(self): 10 | super().__init__() 11 | self.shape('circle') 12 | self.penup() 13 | self.change_color() 14 | self.speed('fastest') 15 | self.shapesize(stretch_wid=0.5, stretch_len=0.5) 16 | self.move() 17 | 18 | def move(self): 19 | self.change_color() 20 | self.goto(random.randint(-260, 260), random.randint(-260, 260)) 21 | 22 | def change_color(self): 23 | self.color(random.choice(self.FOOD_COLORS)) 24 | -------------------------------------------------------------------------------- /Day021/Project/project.md: -------------------------------------------------------------------------------- 1 | # Snake Game - Part 4 - 7 2 | 3 | ## Instructions 4 | 5 | #### Part 4 6 | Detect collision with food 7 | 8 | #### Part 5 9 | Create scoreboard 10 | 11 | #### Part 6 12 | Detect collision with wall 13 | 14 | #### Part 7 15 | Detect collision with tail 16 | -------------------------------------------------------------------------------- /Day022/Project/ball.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle 2 | 3 | 4 | class Ball(Turtle): 5 | SCREEN_HEIGHT = 600 6 | 7 | def __init__(self): 8 | super().__init__() 9 | self.color('white') 10 | self.shape('circle') 11 | self.penup() 12 | 13 | self.is_right = True 14 | self.x_move = 5 15 | self.y_move = 5 16 | self.move_speed = 0.1 17 | 18 | def move(self): 19 | self.goto(self.xcor() + self.x_move, self.ycor() + self.y_move) 20 | 21 | def is_collision_wall(self): 22 | return abs(self.ycor()) > 290 23 | 24 | def is_collision_paddle(self, paddle): 25 | return abs(self.xcor()) > 320 and self.distance(paddle) < 50 26 | 27 | def is_collision_right(self): 28 | return self.xcor() > 380 29 | 30 | def is_collision_left(self): 31 | return self.xcor() < -380 32 | 33 | def bounce_y(self): 34 | self.y_move *= -1 35 | 36 | def bounce_x(self): 37 | self.x_move *= -1 38 | self.move_speed *= 0.9 39 | 40 | def reset_position(self): 41 | self.goto(0, 0) 42 | self.move_speed = 0.1 43 | self.bounce_x() 44 | -------------------------------------------------------------------------------- /Day022/Project/paddle.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle 2 | 3 | 4 | class Paddle(Turtle): 5 | def __init__(self, position): 6 | super().__init__() 7 | self.shape('square') 8 | self.color('white') 9 | self.shapesize(stretch_wid=5, stretch_len=1) 10 | self.penup() 11 | self.goto(position) 12 | 13 | def go_down(self): 14 | x = self.xcor() 15 | y = self.ycor() - 20 16 | if y > -250: 17 | self.goto(x, y) 18 | 19 | def go_up(self): 20 | x = self.xcor() 21 | y = self.ycor() + 30 22 | if y < 250: 23 | self.goto(x, y) 24 | -------------------------------------------------------------------------------- /Day022/Project/project.md: -------------------------------------------------------------------------------- 1 | # Pong 2 | 3 | ## Instructions 4 | 5 | 1. Create the screen 6 | 2. Create and move a paddle 7 | 3. Create another paddle 8 | 4. Create the ball and make it move 9 | 5. Detect collision with a wall and bounce 10 | 6. Detect collision with paddle 11 | 7. Detect when paddle misses 12 | 8. Keep Score 13 | -------------------------------------------------------------------------------- /Day022/Project/sketch_project.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle, Screen 2 | 3 | screen = Screen() 4 | screen.bgcolor('black') 5 | screen.setup(width=800, height=600) 6 | screen.title("Pong") 7 | screen.tracer(0) 8 | 9 | right_paddle = Turtle('square') 10 | right_paddle.color('white') 11 | right_paddle.shapesize(stretch_wid=5, stretch_len=1) 12 | right_paddle.penup() 13 | right_paddle.goto(350, 0) 14 | 15 | 16 | def go_up(): 17 | x = right_paddle.xcor() 18 | y = right_paddle.ycor() + 20 19 | right_paddle.goto(x, y) 20 | 21 | 22 | def go_down(): 23 | x = right_paddle.xcor() 24 | y = right_paddle.ycor() - 20 25 | right_paddle.goto(x, y) 26 | 27 | 28 | screen.listen() 29 | screen.onkey(go_up, 'Up') 30 | screen.onkey(go_down, 'Down') 31 | 32 | game_is_on = True 33 | while game_is_on: 34 | screen.update() 35 | 36 | screen.exitonclick() 37 | -------------------------------------------------------------------------------- /Day023/Capstone_Project/player.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | 3 | 4 | class Player(turtle.Turtle): 5 | STARTING_POSITION = (0, -280) 6 | MOVE_DISTANCE = 10 7 | FINISH_LINE_Y = 280 8 | 9 | def __init__(self): 10 | super().__init__() 11 | self.shape('turtle') 12 | self.up() 13 | self.goto_beginning() 14 | 15 | def goto_beginning(self): 16 | self.goto(self.STARTING_POSITION) 17 | self.setheading(90) 18 | 19 | def move(self): 20 | self.forward(self.MOVE_DISTANCE) 21 | 22 | def end_line(self): 23 | return self.ycor() > self.FINISH_LINE_Y 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Day023/Capstone_Project/project.py: -------------------------------------------------------------------------------- 1 | import time 2 | import random 3 | from turtle import Screen 4 | from player import Player 5 | from car_manager import CarManager 6 | from scoreboard import Scoreboard 7 | 8 | screen = Screen() 9 | screen.setup(width=600, height=600) 10 | screen.tracer(0) 11 | 12 | player = Player() 13 | scoreboard = Scoreboard() 14 | 15 | screen.listen() 16 | screen.onkeypress(player.move, 'Up') 17 | 18 | game_is_on = True 19 | count = 0 20 | car_manager = CarManager() 21 | 22 | while game_is_on: 23 | count += 1 24 | if count % 6 == 0: 25 | car_manager.create_car() 26 | car_manager.move_cars() 27 | time.sleep(0.1) 28 | screen.update() 29 | random.shuffle(car_manager.all_cars) 30 | if player.end_line(): 31 | scoreboard.update_level() 32 | player.goto_beginning() 33 | car_manager.update_level() 34 | 35 | if car_manager.check_collision(player): 36 | game_is_on = False 37 | scoreboard.game_over() 38 | 39 | 40 | 41 | screen.exitonclick() 42 | -------------------------------------------------------------------------------- /Day023/Capstone_Project/scoreboard.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | 3 | 4 | class Scoreboard(turtle.Turtle): 5 | FONT = ("Letters for Learners", 24, "normal") 6 | 7 | def __init__(self): 8 | super().__init__() 9 | self.hideturtle() 10 | self.up() 11 | self.level = 0 12 | self.update_level() 13 | 14 | def update_level(self): 15 | self.level += 1 16 | self.clear() 17 | self.goto(-250, 260) 18 | self.write(f'Level: {self.level}', align='center', font=self.FONT) 19 | 20 | def game_over(self): 21 | self.goto(0, 0) 22 | self.write(f'Game Over.', align='center', font=self.FONT) 23 | -------------------------------------------------------------------------------- /Day024/Challenges/ch.md: -------------------------------------------------------------------------------- 1 | # Challenge 2 | 3 | # Instructions 4 | Make snake game read high score from a file and save high score to a file. 5 | 6 | -------------------------------------------------------------------------------- /Day024/Challenges/ch/data.txt: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /Day024/Challenges/ch/food.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle 2 | import random 3 | 4 | 5 | class Food(Turtle): 6 | 7 | def __init__(self): 8 | super().__init__() 9 | self.shape("circle") 10 | self.penup() 11 | self.shapesize(stretch_len=0.5, stretch_wid=0.5) 12 | self.color("blue") 13 | self.speed("fastest") 14 | self.refresh() 15 | 16 | def refresh(self): 17 | random_x = random.randint(-280, 280) 18 | random_y = random.randint(-280, 280) 19 | self.goto(random_x, random_y) 20 | -------------------------------------------------------------------------------- /Day024/Challenges/ch/main.py: -------------------------------------------------------------------------------- 1 | from turtle import Screen 2 | from snake import Snake 3 | from food import Food 4 | from scoreboard import Scoreboard 5 | import time 6 | 7 | screen = Screen() 8 | screen.setup(width=600, height=600) 9 | screen.bgcolor("black") 10 | screen.title("My Snake Game") 11 | screen.tracer(0) 12 | 13 | snake = Snake() 14 | food = Food() 15 | scoreboard = Scoreboard() 16 | 17 | screen.listen() 18 | screen.onkey(snake.up, "Up") 19 | screen.onkey(snake.down, "Down") 20 | screen.onkey(snake.left, "Left") 21 | screen.onkey(snake.right, "Right") 22 | 23 | game_is_on = True 24 | while game_is_on: 25 | screen.update() 26 | time.sleep(0.1) 27 | snake.move() 28 | 29 | # Detect collision with food. 30 | if snake.head.distance(food) < 15: 31 | food.refresh() 32 | snake.extend() 33 | scoreboard.increase_score() 34 | 35 | # Detect collision with wall. 36 | if abs(snake.head.xcor()) > 280 or abs(snake.head.ycor()) > 280: 37 | scoreboard.reset() 38 | snake.reset() 39 | 40 | # Detect collision with tail. 41 | for segment in snake.segments: 42 | if segment == snake.head: 43 | pass 44 | elif snake.head.distance(segment) < 10: 45 | scoreboard.reset() 46 | 47 | 48 | screen.exitonclick() 49 | -------------------------------------------------------------------------------- /Day024/Challenges/ch/scoreboard.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle 2 | ALIGNMENT = "center" 3 | FONT = ("Courier", 24, "normal") 4 | 5 | 6 | class Scoreboard(Turtle): 7 | 8 | def __init__(self): 9 | super().__init__() 10 | self.score = 0 11 | self.high_score = 0 12 | with open('data.txt') as data: 13 | self.high_score = int(data.read()) 14 | self.color("white") 15 | self.penup() 16 | self.goto(0, 250) 17 | self.hideturtle() 18 | self.update_scoreboard() 19 | 20 | def update_scoreboard(self): 21 | self.clear() 22 | self.write(f"Score: {self.score} High Score: {self.high_score}", align=ALIGNMENT, font=FONT) 23 | 24 | def reset(self): 25 | if self.score > self.high_score: 26 | self.high_score = self.score 27 | with open('data.txt', mode='w') as data: 28 | data.write(str(self.high_score)) 29 | 30 | self.score = 0 31 | self.update_scoreboard() 32 | 33 | def increase_score(self): 34 | self.score += 1 35 | self.update_scoreboard() 36 | -------------------------------------------------------------------------------- /Day024/Lectures/lec01/food.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle 2 | import random 3 | 4 | 5 | class Food(Turtle): 6 | 7 | def __init__(self): 8 | super().__init__() 9 | self.shape("circle") 10 | self.penup() 11 | self.shapesize(stretch_len=0.5, stretch_wid=0.5) 12 | self.color("blue") 13 | self.speed("fastest") 14 | self.refresh() 15 | 16 | def refresh(self): 17 | random_x = random.randint(-280, 280) 18 | random_y = random.randint(-280, 280) 19 | self.goto(random_x, random_y) 20 | -------------------------------------------------------------------------------- /Day024/Lectures/lec01/scoreboard.py: -------------------------------------------------------------------------------- 1 | from turtle import Turtle 2 | ALIGNMENT = "center" 3 | FONT = ("Courier", 24, "normal") 4 | 5 | 6 | class Scoreboard(Turtle): 7 | 8 | def __init__(self): 9 | super().__init__() 10 | self.score = 0 11 | self.high_score = 0 12 | self.color("white") 13 | self.penup() 14 | self.goto(0, 250) 15 | self.hideturtle() 16 | self.update_scoreboard() 17 | 18 | def update_scoreboard(self): 19 | self.clear() 20 | self.write(f"Score: {self.score} High Score: {self.high_score}", align=ALIGNMENT, font=FONT) 21 | 22 | def reset(self): 23 | if self.score > self.high_score: 24 | self.high_score = self.score 25 | self.score = 0 26 | self.update_scoreboard() 27 | 28 | def increase_score(self): 29 | self.score += 1 30 | self.update_scoreboard() 31 | -------------------------------------------------------------------------------- /Day024/Lectures/lec02/main.py: -------------------------------------------------------------------------------- 1 | file = open("my_file.txt") 2 | contents = file.read() 3 | print(contents) 4 | file.close() 5 | 6 | -------------------------------------------------------------------------------- /Day024/Lectures/lec02/my_file.txt: -------------------------------------------------------------------------------- 1 | Hello, my name is Paula! 2 | I am 24 years old. 3 | My favourite food is a bowl of popcorn. 4 | -------------------------------------------------------------------------------- /Day024/Lectures/lec03/main.py: -------------------------------------------------------------------------------- 1 | with open("my_file.txt") as file: 2 | contents = file.read() 3 | print(contents) 4 | 5 | -------------------------------------------------------------------------------- /Day024/Lectures/lec03/my_file.txt: -------------------------------------------------------------------------------- 1 | Hello, my name is Paula! 2 | I am 24 years old. 3 | My favourite food is a bowl of popcorn. 4 | -------------------------------------------------------------------------------- /Day024/Lectures/lec04/main.py: -------------------------------------------------------------------------------- 1 | with open("my_file.txt") as file: 2 | contents = file.read() 3 | print(contents) 4 | 5 | with open("my_file.txt", mode="w") as file: 6 | file.write("New text.\n") 7 | 8 | with open("my_file.txt") as file: 9 | contents = file.read() 10 | print(contents) 11 | -------------------------------------------------------------------------------- /Day024/Lectures/lec04/my_file.txt: -------------------------------------------------------------------------------- 1 | New text. -------------------------------------------------------------------------------- /Day024/Lectures/lec05/main.py: -------------------------------------------------------------------------------- 1 | with open("my_file.txt") as file: 2 | contents = file.read() 3 | print(contents) 4 | 5 | with open("my_file.txt", mode="a") as file: 6 | file.write("New text.") 7 | 8 | with open("my_file.txt") as file: 9 | contents = file.read() 10 | print(contents) 11 | -------------------------------------------------------------------------------- /Day024/Lectures/lec05/my_file.txt: -------------------------------------------------------------------------------- 1 | Hello, my name is Paula! 2 | I am 24 years old. 3 | My favourite food is a bowl of popcorn. 4 | -------------------------------------------------------------------------------- /Day024/Lectures/lec06/main.py: -------------------------------------------------------------------------------- 1 | with open("new_file.txt", mode="w") as file: 2 | file.write("New text.") 3 | -------------------------------------------------------------------------------- /Day024/Lectures/lec06/new_file.txt: -------------------------------------------------------------------------------- 1 | New text. -------------------------------------------------------------------------------- /Day024/Lectures/lec07/Desktop/my_file.txt: -------------------------------------------------------------------------------- 1 | Hello, my name is Paula! 2 | -------------------------------------------------------------------------------- /Day024/Lectures/lec07/main.py: -------------------------------------------------------------------------------- 1 | path = "/home/paula/PycharmProjects/100DaysOfCode/Day024/Lectures/lec07/Desktop" 2 | with open(f'{path}/my_file.txt') as file: 3 | contents = file.read() 4 | print(contents) 5 | 6 | with open("../../Lectures/lec07/Desktop/my_file.txt") as file: 7 | contents = file.read() 8 | print(contents) 9 | -------------------------------------------------------------------------------- /Day024/Project/Input/Letters/starting_letter.docx: -------------------------------------------------------------------------------- 1 | Dear [name], 2 | 3 | You are invited to my birthday this Saturday. 4 | 5 | Hope you can make it! 6 | 7 | Paula 8 | -------------------------------------------------------------------------------- /Day024/Project/Input/Names/invited_names.txt: -------------------------------------------------------------------------------- 1 | Aang 2 | Zuko 3 | Appa 4 | Katara 5 | Sokka 6 | Momo 7 | Uncle Iroh 8 | Toph -------------------------------------------------------------------------------- /Day024/Project/Output/ReadyToSend/example.docx: -------------------------------------------------------------------------------- 1 | Dear Aang, 2 | 3 | You are invited to my birthday this Saturday. 4 | 5 | Hope you can make it! 6 | 7 | Angela 8 | -------------------------------------------------------------------------------- /Day024/Project/Output/ReadyToSend/letter_for_Aang.docx: -------------------------------------------------------------------------------- 1 | Dear Aang, 2 | 3 | You are invited to my birthday this Saturday. 4 | 5 | Hope you can make it! 6 | 7 | Paula 8 | -------------------------------------------------------------------------------- /Day024/Project/Output/ReadyToSend/letter_for_Appa.docx: -------------------------------------------------------------------------------- 1 | Dear Appa, 2 | 3 | You are invited to my birthday this Saturday. 4 | 5 | Hope you can make it! 6 | 7 | Paula 8 | -------------------------------------------------------------------------------- /Day024/Project/Output/ReadyToSend/letter_for_Katara.docx: -------------------------------------------------------------------------------- 1 | Dear Katara, 2 | 3 | You are invited to my birthday this Saturday. 4 | 5 | Hope you can make it! 6 | 7 | Paula 8 | -------------------------------------------------------------------------------- /Day024/Project/Output/ReadyToSend/letter_for_Momo.docx: -------------------------------------------------------------------------------- 1 | Dear Momo, 2 | 3 | You are invited to my birthday this Saturday. 4 | 5 | Hope you can make it! 6 | 7 | Paula 8 | -------------------------------------------------------------------------------- /Day024/Project/Output/ReadyToSend/letter_for_Sokka.docx: -------------------------------------------------------------------------------- 1 | Dear Sokka, 2 | 3 | You are invited to my birthday this Saturday. 4 | 5 | Hope you can make it! 6 | 7 | Paula 8 | -------------------------------------------------------------------------------- /Day024/Project/Output/ReadyToSend/letter_for_Toph.docx: -------------------------------------------------------------------------------- 1 | Dear Toph, 2 | 3 | You are invited to my birthday this Saturday. 4 | 5 | Hope you can make it! 6 | 7 | Paula 8 | -------------------------------------------------------------------------------- /Day024/Project/Output/ReadyToSend/letter_for_Uncle Iroh.docx: -------------------------------------------------------------------------------- 1 | Dear Uncle Iroh, 2 | 3 | You are invited to my birthday this Saturday. 4 | 5 | Hope you can make it! 6 | 7 | Paula 8 | -------------------------------------------------------------------------------- /Day024/Project/Output/ReadyToSend/letter_for_Zuko.docx: -------------------------------------------------------------------------------- 1 | Dear Zuko, 2 | 3 | You are invited to my birthday this Saturday. 4 | 5 | Hope you can make it! 6 | 7 | Paula 8 | -------------------------------------------------------------------------------- /Day024/Project/project.md: -------------------------------------------------------------------------------- 1 | # Mail Merge 2 | 3 | # Instructions 4 | Create a letter using starting_letter.docx 5 | for each name in [`"invited_names.txt"`](./Input/Names/invited_names.txt) 6 | Replace the `name` placeholder with the actual name. 7 | Save the letters in the folder [`"ReadyToSend"`](./Output/ReadyToSend). 8 | 9 | ### Hint 1: 10 | This method will help you: [`file.readlines`](https://www.w3schools.com/python/ref_file_readlines.asp) 11 | ### Hint2: 12 | This method will also help you: [`string.replace`](https://www.w3schools.com/python/ref_string_replace.asp) 13 | ### Hint3: 14 | This method will help you: [`string.strip`](https://www.w3schools.com/python/ref_string_strip.asp) 15 | -------------------------------------------------------------------------------- /Day024/Project/project.py: -------------------------------------------------------------------------------- 1 | with open('./Input/Letters/starting_letter.docx') as file: 2 | email = file.readlines() 3 | 4 | with open('./Input/Names/invited_names.txt') as file: 5 | names = file.readlines() 6 | 7 | old_name = '[name]' 8 | for name in names: 9 | name = name.strip() 10 | email[0] = email[0].replace(f'{old_name}', name) 11 | with open(f'./Output/ReadyToSend/letter_for_{name}.docx', mode='w') as file: 12 | file.writelines(email) 13 | old_name = name 14 | -------------------------------------------------------------------------------- /Day025/Challenge/ch.md: -------------------------------------------------------------------------------- 1 | # Challenge 2 | 3 | ## Instructions 4 | Use the squirrel_census.csv file to create another file named fur_data.csv that has two columns the fur color, and the count of squirrels with that color. 5 | -------------------------------------------------------------------------------- /Day025/Challenge/ch.py: -------------------------------------------------------------------------------- 1 | import pandas 2 | 3 | data = pandas.read_csv('squirrel_census.csv') 4 | 5 | black_count = len(data[data['Primary Fur Color'] == "Black"]) 6 | cinnamon_count = len(data[data['Primary Fur Color'] == "Cinnamon"]) 7 | gray_count = len(data[data['Primary Fur Color'] == "Gray"]) 8 | 9 | colors_dict = { 10 | 'Fur Color': ['Black', 'Cinnamon', 'Gray'], 11 | 'Count': [black_count, cinnamon_count, gray_count] 12 | } 13 | 14 | new_data = pandas.DataFrame(colors_dict) 15 | new_data.to_csv('color_data.csv') 16 | -------------------------------------------------------------------------------- /Day025/Challenge/color_data.csv: -------------------------------------------------------------------------------- 1 | ,Fur Color,Count 2 | 0,Black,103 3 | 1,Cinnamon,392 4 | 2,Gray,2473 5 | -------------------------------------------------------------------------------- /Day025/Lectures/lec01/main.py: -------------------------------------------------------------------------------- 1 | import csv 2 | 3 | with open('weather_data.csv') as data_file: 4 | data = data_file.readlines() 5 | print(data) 6 | print() 7 | 8 | with open('weather_data.csv') as data_file: 9 | data = csv.reader(data_file) 10 | for row in data: 11 | print(row) 12 | print() 13 | 14 | with open('weather_data.csv') as data_file: 15 | data = csv.reader(data_file) 16 | temperatures = [] 17 | for row in data: 18 | if row[1] != "temp": 19 | temperatures.append(int(row[1])) 20 | 21 | print(temperatures) 22 | 23 | -------------------------------------------------------------------------------- /Day025/Lectures/lec01/weather_data.csv: -------------------------------------------------------------------------------- 1 | day,temp,condition 2 | Monday,12,Sunny 3 | Tuesday,14,Rain 4 | Wednesday,15,Rain 5 | Thursday,14,Cloudy 6 | Friday,21,Sunny 7 | Saturday,22,Sunny 8 | Sunday,24,Sunny -------------------------------------------------------------------------------- /Day025/Lectures/lec02/main.py: -------------------------------------------------------------------------------- 1 | import pandas 2 | 3 | data = pandas.read_csv("weather_data.csv") 4 | 5 | print(data) 6 | print() 7 | 8 | print(data["temp"]) 9 | print() 10 | 11 | print(type(data)) 12 | print(type(data["temp"])) 13 | print() 14 | 15 | data_dict = data.to_dict() 16 | print(data_dict) 17 | print() 18 | 19 | temp_list = data["temp"].to_list() 20 | print(temp_list) 21 | print(len(temp_list)) 22 | print() 23 | 24 | print(sum(temp_list) / len(temp_list)) 25 | print(data["temp"].mean()) 26 | print() 27 | 28 | print(data["temp"].max()) 29 | print() 30 | 31 | print(data["condition"]) 32 | print() 33 | 34 | print(data.condition) 35 | print() 36 | 37 | print(data[data.day == "Monday"]) 38 | print() 39 | 40 | print(data[data.temp == data.temp.max()]) 41 | print() 42 | 43 | monday = data[data.day == "Monday"] 44 | print(monday.condition) 45 | 46 | monday_temp_F = monday.temp * 9 / 5 + 32 47 | print(monday_temp_F) 48 | -------------------------------------------------------------------------------- /Day025/Lectures/lec02/weather_data.csv: -------------------------------------------------------------------------------- 1 | day,temp,condition 2 | Monday,12,Sunny 3 | Tuesday,14,Rain 4 | Wednesday,15,Rain 5 | Thursday,14,Cloudy 6 | Friday,21,Sunny 7 | Saturday,22,Sunny 8 | Sunday,24,Sunny 9 | -------------------------------------------------------------------------------- /Day025/Lectures/lec03/main.py: -------------------------------------------------------------------------------- 1 | import pandas 2 | 3 | data_dict = { 4 | "students": ["Amy", "James", "Angela"], 5 | "score": [76, 56, 65] 6 | } 7 | 8 | data = pandas.DataFrame(data_dict) 9 | print(data) 10 | 11 | data.to_csv("score_data.csv") 12 | -------------------------------------------------------------------------------- /Day025/Lectures/lec03/score_data.csv: -------------------------------------------------------------------------------- 1 | ,students,score 2 | 0,Amy,76 3 | 1,James,56 4 | 2,Angela,65 5 | -------------------------------------------------------------------------------- /Day025/Project/project.md: -------------------------------------------------------------------------------- 1 | # U.S States Game 2 | 3 | # Instructions 4 | Using turtle replicate the game [`states`](https://www.sporcle.com/games/g/states). 5 | 6 | 1. Convert the guess to Title case 7 | 2. Check if the guess is among the 50 states 8 | 3. Write the correct guesses onto the map 9 | 4. Use a loop to allow the user to keep guessing 10 | 5. Record the correct guesses in a list 11 | 6. Keep track of the score 12 | 7. Add a secret word to exit the game 13 | 8. Generate a states_to_learn.csv file with the states the user needs to learn. 14 | -------------------------------------------------------------------------------- /Day025/Project/states.csv: -------------------------------------------------------------------------------- 1 | state,x,y 2 | Alabama,139,-77 3 | Alaska,-204,-170 4 | Arizona,-203,-40 5 | Arkansas,57,-53 6 | California,-297,13 7 | Colorado,-112,20 8 | Connecticut,297,96 9 | Delaware,275,42 10 | Florida,220,-145 11 | Georgia,182,-75 12 | Hawaii,-317,-143 13 | Idaho,-216,122 14 | Illinois,95,37 15 | Indiana,133,39 16 | Iowa,38,65 17 | Kansas,-17,5 18 | Kentucky,149,1 19 | Louisiana,59,-114 20 | Maine,319,164 21 | Maryland,288,27 22 | Massachusetts,312,112 23 | Michigan,148,101 24 | Minnesota,23,135 25 | Mississippi,94,-78 26 | Missouri,49,6 27 | Montana,-141,150 28 | Nebraska,-61,66 29 | Nevada,-257,56 30 | New Hampshire,302,127 31 | New Jersey,282,65 32 | New Mexico,-128,-43 33 | New York,236,104 34 | North Carolina,239,-22 35 | North Dakota,-44,158 36 | Ohio,176,52 37 | Oklahoma,-8,-41 38 | Oregon,-278,138 39 | Pennsylvania,238,72 40 | Rhode Island,318,94 41 | South Carolina,218,-51 42 | South Dakota,-44,109 43 | Tennessee,131,-34 44 | Texas,-38,-106 45 | Utah,-189,34 46 | Vermont,282,154 47 | Virginia,234,12 48 | Washington,-257,193 49 | West Virginia,200,20 50 | Wisconsin,83,113 51 | Wyoming,-134,90 -------------------------------------------------------------------------------- /Day025/Project/states_to_learn.csv: -------------------------------------------------------------------------------- 1 | ,0 2 | 0,Alabama 3 | -------------------------------------------------------------------------------- /Day025/Project/us_states.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day025/Project/us_states.gif -------------------------------------------------------------------------------- /Day026/Exercises/ex01.md: -------------------------------------------------------------------------------- 1 | ## List Comprehension 1 2 | 3 | # Instructions 4 | 5 | You are going to write a List Comprehension to create a new list called `squared_numbers`. This new list should contain every number in the list `numbers` but each number should be squared. 6 | 7 | ``` 8 | e.g. `4 * 4 = 16` 9 | ``` 10 | 11 | ``` 12 | 4 squared equals 16. 13 | ``` 14 | 15 | **DO NOT** modify the List `numbers` directly. Try to use **List Comprehension** instead of a **Loop**. 16 | 17 | # Example Output 18 | 19 | ``` 20 | [1, 1, 4, 9, 25, 64, 169, 441, 1156, 3025] 21 | ``` 22 | 23 | # Hint 24 | 25 | 1. Use the keyword method for starting the List comprehension and fill in the relevant parts. 26 | 27 | 2. Make sure the squared_numbers is printed into the console for the code checking to work. 28 | 29 | # Test Your Code 30 | 31 | Before checking the solution, try copy-pasting your code into this repl: 32 | 33 | [https://repl.it/@appbrewery/day-26-1-test-your-code](https://repl.it/@appbrewery/day-26-1-test-your-code) 34 | 35 | This repl includes my testing code that will check if your code meets this assignment's objectives. 36 | 37 | 38 | 39 | # Solution 40 | 41 | [https://repl.it/@appbrewery/day-26-1-solution](https://repl.it/@appbrewery/day-26-1-solution) 42 | -------------------------------------------------------------------------------- /Day026/Exercises/ex01.py: -------------------------------------------------------------------------------- 1 | numbers = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] 2 | 3 | squared_numbers = [number ** 2 for number in numbers] 4 | print(squared_numbers) 5 | -------------------------------------------------------------------------------- /Day026/Exercises/ex02.md: -------------------------------------------------------------------------------- 1 | ## List Comprehension 2 2 | 3 | # Instructions 4 | 5 | You are going to write a List Comprehension to create a new list called `result`. This new list should only contain the even numbers from the list `numbers`. 6 | 7 | **DO NOT** modify the List `numbers` directly. Try to use **List Comprehension** instead of a **Loop**. 8 | 9 | # Example Output 10 | 11 | ``` 12 | [2, 8, 34] 13 | ``` 14 | 15 | # Hint 16 | 17 | 1. Use the keyword method for starting the List comprehension and fill in the relevant parts. 18 | 19 | 2. Even numbers can be divided by 2 with no remainder. 20 | 21 | 3. Remind yourself of how the modulo operator works. 22 | 23 | # Test Your Code 24 | 25 | Before checking the solution, try copy-pasting your code into this repl: 26 | 27 | [https://repl.it/@appbrewery/day-26-2-test-your-code](https://repl.it/@appbrewery/day-26-2-test-your-code) 28 | 29 | This repl includes my testing code that will check if your code meets this assignment's objectives. 30 | 31 | 32 | 33 | # Solution 34 | 35 | [https://repl.it/@appbrewery/day-26-2-solution](https://repl.it/@appbrewery/day-26-2-solution) 36 | -------------------------------------------------------------------------------- /Day026/Exercises/ex02.py: -------------------------------------------------------------------------------- 1 | numbers = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] 2 | 3 | result = [number for number in numbers if number % 2 == 0] 4 | 5 | print(result) 6 | -------------------------------------------------------------------------------- /Day026/Exercises/ex03.py: -------------------------------------------------------------------------------- 1 | with open('file1.txt') as file: 2 | numbers1 = file.readlines() 3 | 4 | with open('file2.txt') as file: 5 | numbers2 = file.readlines() 6 | 7 | result = [int(number) for number in numbers1 if number in numbers2] 8 | print(result) 9 | -------------------------------------------------------------------------------- /Day026/Exercises/ex04.py: -------------------------------------------------------------------------------- 1 | sentence = "What is the Airspeed Velocity of an Unladen Swallow?" 2 | 3 | result = {word: len(word) for word in sentence.split()} 4 | print(result) 5 | -------------------------------------------------------------------------------- /Day026/Exercises/ex05.py: -------------------------------------------------------------------------------- 1 | def celsius_to_fahrenheit(celsius): 2 | return celsius * 9 / 5 + 32 3 | 4 | 5 | weather_celsius = { 6 | "Monday": 12, 7 | "Tuesday": 14, 8 | "Wednesday": 15, 9 | "Thursday": 14, 10 | "Friday": 21, 11 | "Saturday": 22, 12 | "Sunday": 24, 13 | } 14 | 15 | weather_fahrenheit = {day: celsius_to_fahrenheit(celsius) for (day, celsius) in weather_celsius.items()} 16 | print(weather_fahrenheit) 17 | -------------------------------------------------------------------------------- /Day026/Exercises/file1.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 6 3 | 5 4 | 8 5 | 33 6 | 12 7 | 7 8 | 4 9 | 72 10 | 2 11 | 42 12 | 13 13 | -------------------------------------------------------------------------------- /Day026/Exercises/file2.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 6 3 | 13 4 | 5 5 | 7 6 | 89 7 | 12 8 | 3 9 | 33 10 | 34 11 | 1 12 | 344 13 | 42 14 | -------------------------------------------------------------------------------- /Day026/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | numbers = [1, 2, 3] 2 | 3 | numbers_plus_one = [n + 1 for n in numbers] 4 | print(numbers_plus_one) 5 | 6 | name = "Angela" 7 | letters = [letter for letter in name] 8 | print(letters) 9 | 10 | values = [num * 2 for num in range(1, 5)] 11 | print(values) 12 | print() 13 | 14 | names = ["Alex", "Beth", "Caroline", "Dave", "Eleanor", "Freddie"] 15 | short_names = [name for name in names if len(name) < 5] 16 | print(short_names) 17 | 18 | long_names = [name.upper() for name in names if len(name) >= 5] 19 | print(long_names) 20 | -------------------------------------------------------------------------------- /Day026/Lectures/lec02/states.csv: -------------------------------------------------------------------------------- 1 | state,x,y 2 | Alabama,139,-77 3 | Alaska,-204,-170 4 | Arizona,-203,-40 5 | Arkansas,57,-53 6 | California,-297,13 7 | Colorado,-112,20 8 | Connecticut,297,96 9 | Delaware,275,42 10 | Florida,220,-145 11 | Georgia,182,-75 12 | Hawaii,-317,-143 13 | Idaho,-216,122 14 | Illinois,95,37 15 | Indiana,133,39 16 | Iowa,38,65 17 | Kansas,-17,5 18 | Kentucky,149,1 19 | Louisiana,59,-114 20 | Maine,319,164 21 | Maryland,288,27 22 | Massachusetts,312,112 23 | Michigan,148,101 24 | Minnesota,23,135 25 | Mississippi,94,-78 26 | Missouri,49,6 27 | Montana,-141,150 28 | Nebraska,-61,66 29 | Nevada,-257,56 30 | New Hampshire,302,127 31 | New Jersey,282,65 32 | New Mexico,-128,-43 33 | New York,236,104 34 | North Carolina,239,-22 35 | North Dakota,-44,158 36 | Ohio,176,52 37 | Oklahoma,-8,-41 38 | Oregon,-278,138 39 | Pennsylvania,238,72 40 | Rhode Island,318,94 41 | South Carolina,218,-51 42 | South Dakota,-44,109 43 | Tennessee,131,-34 44 | Texas,-38,-106 45 | Utah,-189,34 46 | Vermont,282,154 47 | Virginia,234,12 48 | Washington,-257,193 49 | West Virginia,200,20 50 | Wisconsin,83,113 51 | Wyoming,-134,90 -------------------------------------------------------------------------------- /Day026/Lectures/lec02/states_to_learn.csv: -------------------------------------------------------------------------------- 1 | ,0 2 | 0,Idaho 3 | 1,Indiana 4 | 2,Kansas 5 | 3,Minnesota 6 | 4,Oklahoma 7 | 5,Oregon 8 | 6,Rhode Island 9 | 7,Tennessee 10 | 8,Vermont 11 | 9,West Virginia 12 | -------------------------------------------------------------------------------- /Day026/Lectures/lec02/us_states.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day026/Lectures/lec02/us_states.gif -------------------------------------------------------------------------------- /Day026/Lectures/lec02/wrong.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day026/Lectures/lec02/wrong.png -------------------------------------------------------------------------------- /Day026/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | 3 | names = ["Alex", "Beth", "Caroline", "Dave", "Eleanor", "Freddie"] 4 | 5 | student_score = {student: randint(0, 100) for student in names} 6 | print(student_score) 7 | 8 | passed_students = {student: score for (student, score) in student_score.items() if score >= 60} 9 | print(passed_students) 10 | -------------------------------------------------------------------------------- /Day026/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | import pandas 2 | 3 | student_dict = { 4 | "student": ["Angela", "James", "Lily"], 5 | "score": [56, 76, 98] 6 | } 7 | 8 | for (student, score) in student_dict.items(): 9 | print(f'Students: {student}') 10 | print(f'Scores: {score}') 11 | print() 12 | 13 | student_data_frame = pandas.DataFrame(student_dict) 14 | print(student_data_frame) 15 | print() 16 | 17 | for (student, score) in student_data_frame.items(): 18 | print(student) 19 | print(score) 20 | print() 21 | 22 | for (index, row) in student_data_frame.iterrows(): 23 | print(index) 24 | print(row) 25 | print() 26 | 27 | for (index, row) in student_data_frame.iterrows(): 28 | print(row.student) 29 | print(row.score) 30 | print() 31 | 32 | for (index, row) in student_data_frame.iterrows(): 33 | if row.student == "Angela": 34 | print(row.score) 35 | 36 | -------------------------------------------------------------------------------- /Day026/Project/nato_phonetic_alphabet.csv: -------------------------------------------------------------------------------- 1 | letter,code 2 | A,Alfa 3 | B,Bravo 4 | C,Charlie 5 | D,Delta 6 | E,Echo 7 | F,Foxtrot 8 | G,Golf 9 | H,Hotel 10 | I,India 11 | J,Juliet 12 | K,Kilo 13 | L,Lima 14 | M,Mike 15 | N,November 16 | O,Oscar 17 | P,Papa 18 | Q,Quebec 19 | R,Romeo 20 | S,Sierra 21 | T,Tango 22 | U,Uniform 23 | V,Victor 24 | W,Whiskey 25 | X,X-ray 26 | Y,Yankee 27 | Z,Zulu -------------------------------------------------------------------------------- /Day026/Project/project.md: -------------------------------------------------------------------------------- 1 | # Nato Alphabet 2 | 3 | # Instructions 4 | Ask the user for a word and give him the NATO code words that spell that word. 5 | 6 | ### TODO 1. 7 | Create a dictionary in this format: 8 | 9 | ``` 10 | { 11 | "A": "Alfa", 12 | "B": "Bravo" 13 | } 14 | ``` 15 | 16 | ### TODO 2. 17 | Create a list of the phonetic code words from a word that the user inputs. 18 | 19 | # Example Output 20 | 21 | ``` 22 | Enter an word:> paula 23 | The NATO code for PAULA is: 24 | ['Papa', 'Alfa', 'Uniform', 'Lima', 'Alfa'] 25 | 26 | ``` 27 | OBS.: `>` represents input 28 | -------------------------------------------------------------------------------- /Day026/Project/project.py: -------------------------------------------------------------------------------- 1 | import pandas 2 | 3 | data_frame = pandas.read_csv('nato_phonetic_alphabet.csv') 4 | 5 | nato_dict = {row.letter: row.code for (index, row) in data_frame.iterrows()} 6 | 7 | word = input('Enter an word: ').upper() 8 | 9 | spelling_word = [nato_dict[letter] for letter in word] 10 | 11 | print(f'The NATO code for {word} is:') 12 | print(' - '.join(spelling_word)) 13 | -------------------------------------------------------------------------------- /Day027/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | 3 | FONT = ("Letters for Learners", 16, "bold") 4 | window = tkinter.Tk() 5 | window.title("My First GUI Program") 6 | window.minsize(width=500, height=300) 7 | 8 | label = tkinter.Label(text="I am a Label", font=FONT) 9 | label.pack() 10 | 11 | window.mainloop() 12 | -------------------------------------------------------------------------------- /Day027/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | 3 | FONT = ("Letters for Learners", 16, "bold") 4 | window = tkinter.Tk() 5 | window.title("My First GUI Program") 6 | window.minsize(width=500, height=300) 7 | 8 | label = tkinter.Label(text="I am a Label", font=FONT) 9 | label.pack(expand=True) 10 | 11 | window.mainloop() 12 | -------------------------------------------------------------------------------- /Day027/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | 3 | FONT = ("Letters for Learners", 16, "bold") 4 | window = tkinter.Tk() 5 | window.title("My First GUI Program") 6 | window.minsize(width=500, height=300) 7 | 8 | label = tkinter.Label(text="I am a Label", font=FONT) 9 | label.pack(side='left') 10 | 11 | window.mainloop() 12 | -------------------------------------------------------------------------------- /Day027/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | def function(a='A', b='B', c='C'): 2 | print(a, b, c) 3 | 4 | 5 | function() 6 | function(a='C', c='A') 7 | function('*', '_', '*') 8 | -------------------------------------------------------------------------------- /Day027/Lectures/lec05.py: -------------------------------------------------------------------------------- 1 | def function(*args): 2 | print(args) 3 | print(type(args)) 4 | for arg in args: 5 | print(arg, end=' ') 6 | print('\n') 7 | 8 | 9 | def add(*args): 10 | total = 0 11 | for arg in args: 12 | total += arg 13 | return total 14 | 15 | 16 | def other_function(*args): 17 | print(args[0]) 18 | 19 | 20 | function(3, 5, 6) 21 | function(3, 5, 6, 7) 22 | 23 | print(add(3, 5, 6)) 24 | print(add(3, 5, 6, 2, 1)) 25 | print(add(3, 5, 6, 2, 1, 7, 4, 3)) 26 | print() 27 | 28 | other_function(1, 2, 3) 29 | other_function(-1, 0, 1, 2, 3) 30 | -------------------------------------------------------------------------------- /Day027/Lectures/lec06.py: -------------------------------------------------------------------------------- 1 | def function(**kwargs): 2 | print(kwargs) 3 | print(type(kwargs)) 4 | 5 | 6 | def other_function(**kwargs): 7 | for key, value in kwargs.items(): 8 | print(f'Key: {key}, Value: {value}') 9 | 10 | 11 | def another_function(**kwargs): 12 | print(kwargs['add']) 13 | print(kwargs['mul']) 14 | 15 | 16 | def calculate(n, **kwargs): 17 | n += kwargs['add'] 18 | n *= kwargs['mul'] 19 | print(f'n is {n}') 20 | 21 | 22 | function(add='Addition', mul='Multiplication') 23 | print() 24 | 25 | other_function(add='Addition', mul='Multiplication') 26 | print() 27 | 28 | another_function(add='Addition', mul='Multiplication') 29 | print() 30 | 31 | calculate(10, add=10, mul=23) 32 | print() 33 | 34 | 35 | class Car: 36 | def __init__(self, **kw): 37 | self.make = kw.get("make") 38 | self.model = kw.get("model") 39 | self.colour = kw.get("colour") 40 | self.seats = kw.get("seats") 41 | 42 | 43 | car1 = Car(make='Nissan', model='GT-R', colour='Red', seats='5') 44 | print(car1.make) 45 | print(car1.model) 46 | print(car1.colour) 47 | print(car1.seats) 48 | print() 49 | 50 | car2 = Car(make='Nissan', model='Skyline') 51 | print(car2.make) 52 | print(car2.model) 53 | print(car2.colour) 54 | print(car2.seats) 55 | -------------------------------------------------------------------------------- /Day027/Lectures/lec07.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | FONT = ("Letters for Learners", 16, "bold") 4 | window = Tk() 5 | window.title("My First GUI Program") 6 | window.minsize(width=500, height=300) 7 | 8 | label = Label(text="I am a Label", font=FONT) 9 | label.pack(side='left') 10 | 11 | label["text"] = "I am still a Label" 12 | label.config(text="Nope. Still a Label") 13 | 14 | window.mainloop() 15 | -------------------------------------------------------------------------------- /Day027/Lectures/lec08.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | 3 | FONT = ("Letters for Learners", 16, "bold") 4 | window = tkinter.Tk() 5 | window.title("My First GUI Program") 6 | window.minsize(width=500, height=300) 7 | 8 | label = tkinter.Label(text="I am a Label", font=FONT) 9 | label.pack() 10 | 11 | label["text"] = "I am still a Label" 12 | label.config(text="Nope. Still a Label") 13 | 14 | 15 | def button_clicked(): 16 | print("I got clicked") 17 | 18 | 19 | button = tkinter.Button(text="Click Me", command=button_clicked) 20 | button.pack() 21 | 22 | window.mainloop() 23 | -------------------------------------------------------------------------------- /Day027/Lectures/lec09.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | 3 | FONT = ("Letters for Learners", 16, "bold") 4 | window = tkinter.Tk() 5 | window.title("My First GUI Program") 6 | window.minsize(width=500, height=300) 7 | 8 | label = tkinter.Label(text="I am a Label", font=FONT) 9 | label.pack() 10 | 11 | 12 | def button_clicked(): 13 | label.config(text="I am Still a Label") 14 | 15 | 16 | button = tkinter.Button(text="Click Me", font=FONT, command=button_clicked) 17 | button.pack() 18 | 19 | window.mainloop() 20 | -------------------------------------------------------------------------------- /Day027/Lectures/lec10.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | 3 | FONT = ("Letters for Learners", 16, "bold") 4 | window = tkinter.Tk() 5 | window.title("My First GUI Program") 6 | window.minsize(width=500, height=300) 7 | 8 | label = tkinter.Label(text="I am a Label", font=FONT) 9 | label.pack() 10 | 11 | 12 | def button_clicked(): 13 | string = tk_input.get() 14 | label.config(text=string, font=FONT) 15 | 16 | 17 | button = tkinter.Button(text="Click Me", font=FONT, command=button_clicked) 18 | button.pack() 19 | 20 | tk_input = tkinter.Entry(width=10, font=FONT) 21 | tk_input.pack() 22 | 23 | window.mainloop() 24 | -------------------------------------------------------------------------------- /Day027/Lectures/lec12.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | 3 | FONT = ("Letters for Learners", 16, "bold") 4 | 5 | 6 | def button_clicked(): 7 | string = tk_input.get() 8 | label.config(text=string, font=FONT) 9 | 10 | 11 | window = tkinter.Tk() 12 | window.title("My First GUI Program") 13 | window.minsize(width=500, height=300) 14 | 15 | label = tkinter.Label(text="I am a Label", font=FONT) 16 | button = tkinter.Button(text="Click Me", font=FONT, command=button_clicked) 17 | tk_input = tkinter.Entry(width=10, font=FONT) 18 | 19 | label.pack(side='left') 20 | button.pack(side='left') 21 | tk_input.pack(side='left') 22 | 23 | window.mainloop() 24 | -------------------------------------------------------------------------------- /Day027/Lectures/lec13.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | 3 | FONT = ("Letters for Learners", 16, "bold") 4 | 5 | 6 | def button_clicked(): 7 | string = tk_input.get() 8 | label.config(text=string, font=FONT) 9 | 10 | 11 | window = tkinter.Tk() 12 | window.title("My First GUI Program") 13 | window.minsize(width=500, height=300) 14 | 15 | label = tkinter.Label(text="I am a Label", font=FONT) 16 | button = tkinter.Button(text="Click Me", font=FONT, command=button_clicked) 17 | tk_input = tkinter.Entry(width=10, font=FONT) 18 | 19 | label.place(x=0, y=0) 20 | button.place(x=100, y=50) 21 | tk_input.place(x=0, y=100) 22 | 23 | window.mainloop() 24 | -------------------------------------------------------------------------------- /Day027/Lectures/lec14.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | 3 | FONT = ("Letters for Learners", 16, "bold") 4 | 5 | 6 | def button_clicked(): 7 | string = tk_input.get() 8 | label.config(text=string, font=FONT) 9 | 10 | 11 | window = tkinter.Tk() 12 | window.title("My First GUI Program") 13 | window.minsize(width=500, height=300) 14 | 15 | label = tkinter.Label(text="I am a Label", font=FONT) 16 | button = tkinter.Button(text="Click Me", font=FONT, command=button_clicked) 17 | tk_input = tkinter.Entry(width=10, font=FONT) 18 | 19 | label.grid(column=0, row=0) 20 | button.grid(column=1, row=1) 21 | tk_input.grid(column=2, row=2) 22 | 23 | window.mainloop() 24 | -------------------------------------------------------------------------------- /Day027/Lectures/lec15.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | 3 | FONT = ("Letters for Learners", 16, "bold") 4 | 5 | 6 | def button_clicked(): 7 | string = tk_input.get() 8 | label.config(text=string, font=FONT) 9 | 10 | 11 | window = tkinter.Tk() 12 | window.title("My First GUI Program") 13 | window.minsize(width=500, height=300) 14 | window.config(padx=20, pady=20) 15 | 16 | label = tkinter.Label(text="I am a Label", font=FONT) 17 | button1 = tkinter.Button(text="Click Me 1", font=FONT, command=button_clicked) 18 | button2 = tkinter.Button(text="Click Me 2", font=FONT, command=button_clicked) 19 | tk_input = tkinter.Entry(width=10, font=FONT) 20 | 21 | label.config(padx=20, pady=20) 22 | button1.config(padx=20, pady=20) 23 | button2.config(padx=20, pady=20) 24 | 25 | label.grid(column=0, row=0) 26 | button1.grid(column=1, row=1) 27 | button2.grid(column=2, row=0) 28 | tk_input.grid(column=3, row=2) 29 | 30 | window.mainloop() 31 | -------------------------------------------------------------------------------- /Day027/Project/converter_application.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day027/Project/converter_application.png -------------------------------------------------------------------------------- /Day027/Project/project.md: -------------------------------------------------------------------------------- 1 | # Mile to Km Converter 2 | 3 | # Instructions 4 | Using Tkinter create a Mile to Km Converter. 5 | 6 | # Example Output 7 | ![](converter_application.png) 8 | -------------------------------------------------------------------------------- /Day027/Project/project.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | FONT = ("Letters for Learners", 24, "bold") 4 | 5 | 6 | def calculate(): 7 | km = float(entry.get()) * 1.60934 8 | label4.config(text=f'{km:.5f}') 9 | 10 | 11 | window = Tk() 12 | window.title("Mile to Km Converter") 13 | window.minsize(width=200, height=200) 14 | 15 | label1 = Label(text='Miles', font=FONT, padx=10, pady=10) 16 | label2 = Label(text='Km', font=FONT, padx=10, pady=10) 17 | label3 = Label(text='is equal to', font=FONT, padx=10, pady=10) 18 | label4 = Label(text='', font=FONT, padx=10, pady=10) 19 | 20 | button = Button(text='Calculate', command=calculate, font=FONT, padx=10, pady=10) 21 | 22 | entry = Entry(width=8, font=FONT) 23 | 24 | label1.grid(column=2, row=0) 25 | label2.grid(column=2, row=1) 26 | label3.grid(column=0, row=1) 27 | label4.grid(column=1, row=1) 28 | button.grid(column=1, row=2) 29 | entry.grid(column=1, row=0) 30 | 31 | window.mainloop() 32 | -------------------------------------------------------------------------------- /Day028/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | a = 3 2 | print(type(a)) 3 | 4 | a = "Hello" 5 | print(type(a)) 6 | -------------------------------------------------------------------------------- /Day028/Project/pomodoro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day028/Project/pomodoro.png -------------------------------------------------------------------------------- /Day028/Project/project.md: -------------------------------------------------------------------------------- 1 | # Pomodoro App 2 | 3 | # Instructions 4 | Create a Pomodoro timer using Tkinter. 5 | 6 | # Example Output 7 | ![](pomodoro.png) 8 | -------------------------------------------------------------------------------- /Day028/Project/sounds/long_break_time.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day028/Project/sounds/long_break_time.mp3 -------------------------------------------------------------------------------- /Day028/Project/sounds/short_break_time.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day028/Project/sounds/short_break_time.mp3 -------------------------------------------------------------------------------- /Day028/Project/sounds/work_time.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day028/Project/sounds/work_time.mp3 -------------------------------------------------------------------------------- /Day028/Project/tomato.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day028/Project/tomato.png -------------------------------------------------------------------------------- /Day029/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | window = Tk() 4 | 5 | red = Label(bg="red", width=20, height=5) 6 | green = Label(bg="green", width=20, height=5) 7 | blue = Label(bg="blue", width=20, height=5) 8 | 9 | 10 | red.grid(row=0, column=0) 11 | green.grid(row=1, column=1) 12 | blue.grid(row=2, column=0) 13 | 14 | window.mainloop() 15 | -------------------------------------------------------------------------------- /Day029/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | window = Tk() 4 | 5 | red = Label(bg="red", width=20, height=5) 6 | green = Label(bg="green", width=20, height=5) 7 | blue = Label(bg="blue", width=40, height=5) 8 | 9 | 10 | red.grid(row=0, column=0) 11 | green.grid(row=1, column=1) 12 | blue.grid(row=2, column=0) 13 | 14 | window.mainloop() 15 | -------------------------------------------------------------------------------- /Day029/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | window = Tk() 4 | 5 | red = Label(bg="red", width=20, height=5) 6 | green = Label(bg="green", width=20, height=5) 7 | blue = Label(bg="blue", width=40, height=5) 8 | 9 | 10 | red.grid(row=0, column=0) 11 | green.grid(row=1, column=1) 12 | blue.grid(row=2, column=0, columnspan=2) 13 | 14 | window.mainloop() 15 | -------------------------------------------------------------------------------- /Day029/Project/padlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day029/Project/padlock.png -------------------------------------------------------------------------------- /Day029/Project/passwords.csv: -------------------------------------------------------------------------------- 1 | website,username,password 2 | Python,pullynnhah,guido 3 | MyPass,pullynnhah,password 4 | Fake,pullynnhah,qwerty123 5 | Udemy,pullynnhah,dEnib0p8&p&4P7 6 | Discord,pullynnhah,4%W2$z$MHo2cYKs5t 7 | PyPI,pullynnhah,gkw3ngv#UP6(52 8 | MyPass1,pullynnhah,+IRB4PCX(8+#a7c 9 | -------------------------------------------------------------------------------- /Day029/Project/project.md: -------------------------------------------------------------------------------- 1 | # Password Manager 2 | 3 | ## Instructions 4 | 5 | Using Tkinter create a password manager. 6 | The following steps can be considered **challenges**: 7 | 8 | OBS.: You may have to use different values in your program 9 | 1. Configure the window like the following image: 10 | ![](project_img1.png) 11 | 12 | 2. Configure the widgets, so the window looks like the following image: 13 | ![](project_img2.png) 14 | 15 | 3. Save the data to the [passwords.csv](passwords.csv) file and delete the filled entries. 16 | 17 | 4. Create a popup that asks the user if he is sure he wants to add the data to the csv file. 18 | 19 | 5. Create a popup that inform the user if he left any field empty. 20 | 21 | 6. Use the project of day 5 to generate a password when he clicks the button **generate password** 22 | 23 | 7. Add a functionality to auto copy the password generated to the clipboard. 24 | -------------------------------------------------------------------------------- /Day029/Project/project_img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day029/Project/project_img1.png -------------------------------------------------------------------------------- /Day029/Project/project_img2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day029/Project/project_img2.png -------------------------------------------------------------------------------- /Day030/Exercises/ex01.md: -------------------------------------------------------------------------------- 1 | ## IndexError Handling 2 | 3 | # Issue 4 | 5 | We've got some buggy code. Try running the code. The code will crash and give you an **IndexError**. This is because we're looking through the list of `fruits` for an index that is out of range. 6 | 7 | 8 | # Bad Output 9 | 10 | ![](https://cdn.fs.teachablecdn.com/GNPYLwHXQFOUTylnvWvK) 11 | 12 | # Instructions 13 | 14 | Use what you've learnt about exception handling to **prevent** the program from crashing. If the user enters something that is out of range just print a default output of `"Fruit pie"`. e.g. 15 | 16 | 17 | ![](https://cdn.fs.teachablecdn.com/6sNP0lqETeG99crht28k) 18 | 19 | 20 | 21 | # Hint 22 | 23 | 1. You'll need to catch the IndexError exception. 24 | 25 | 2. You'll need the try, except and else keywords. 26 | 27 | # Test Your Code 28 | 29 | Before checking the solution, try copy-pasting your code into this repl: 30 | 31 | [https://repl.it/@appbrewery/day-30-1-test-your-code](https://repl.it/@appbrewery/day-30-1-test-your-code) 32 | 33 | This repl includes my testing code that will check if your code meets this assignment's objectives. 34 | 35 | 36 | # Solution 37 | 38 | [https://repl.it/@appbrewery/day-30-1-solution](https://repl.it/@appbrewery/day-30-1-solution) 39 | -------------------------------------------------------------------------------- /Day030/Exercises/ex01.py: -------------------------------------------------------------------------------- 1 | fruits = ["Apple", "Pear", "Orange"] 2 | 3 | 4 | def make_pie(index): 5 | try: 6 | fruit = fruits[index] 7 | except IndexError: 8 | print("Fruit pie") 9 | else: 10 | print(fruit + " pie") 11 | 12 | 13 | make_pie(0) 14 | make_pie(1) 15 | make_pie(2) 16 | make_pie(3) 17 | make_pie(4) 18 | -------------------------------------------------------------------------------- /Day030/Exercises/ex02.md: -------------------------------------------------------------------------------- 1 | ## KeyError Handling 2 | 3 | # Issue 4 | 5 | We've got some buggy code, try running the code. The code will crash and give you a **KeyError**. This is because some of the posts in the `facebook_posts` don't have any `"Likes"`. 6 | 7 | 8 | # Bad Output 9 | 10 | ![](https://cdn.fs.teachablecdn.com/u1humLqATmXKtN2Uec9A) 11 | 12 | # Instructions 13 | 14 | Use what you've learnt about exception handling to **prevent** the program from crashing. 15 | 16 | 17 | # Hint 18 | 19 | 1. You'll need to catch the KeyError exception. 20 | 21 | 2. Posts without any likes can be counted as 0 likes. 22 | 23 | 24 | # Solution 25 | 26 | [https://repl.it/@appbrewery/day-30-2-solution](https://repl.it/@appbrewery/day-30-2-solution) 27 | -------------------------------------------------------------------------------- /Day030/Exercises/ex02.py: -------------------------------------------------------------------------------- 1 | facebook_posts = [ 2 | {'Likes': 21, 'Comments': 2}, 3 | {'Likes': 13, 'Comments': 2, 'Shares': 1}, 4 | {'Likes': 33, 'Comments': 8, 'Shares': 3}, 5 | {'Comments': 4, 'Shares': 2}, 6 | {'Comments': 1, 'Shares': 1}, 7 | {'Likes': 19, 'Comments': 3} 8 | ] 9 | 10 | total_likes = 0 11 | 12 | for post in facebook_posts: 13 | try: 14 | total_likes += post["Likes"] 15 | except KeyError: 16 | pass 17 | 18 | print(total_likes) 19 | -------------------------------------------------------------------------------- /Day030/Exercises/ex03/ex03.md: -------------------------------------------------------------------------------- 1 | ## NATO Phonetic Alphabet Error Handling 2 | 3 | # Issue 4 | 5 | When the user enters a string containing characters not in the english alphabet you program gives an error. 6 | 7 | 8 | # Instructions 9 | 10 | Fix this problem by prompting the user to enter a new word when this error occurs. 11 | -------------------------------------------------------------------------------- /Day030/Exercises/ex03/nato_phonetic_alphabet.csv: -------------------------------------------------------------------------------- 1 | letter,code 2 | A,Alfa 3 | B,Bravo 4 | C,Charlie 5 | D,Delta 6 | E,Echo 7 | F,Foxtrot 8 | G,Golf 9 | H,Hotel 10 | I,India 11 | J,Juliet 12 | K,Kilo 13 | L,Lima 14 | M,Mike 15 | N,November 16 | O,Oscar 17 | P,Papa 18 | Q,Quebec 19 | R,Romeo 20 | S,Sierra 21 | T,Tango 22 | U,Uniform 23 | V,Victor 24 | W,Whiskey 25 | X,X-ray 26 | Y,Yankee 27 | Z,Zulu -------------------------------------------------------------------------------- /Day030/Exercises/ex03/project.py: -------------------------------------------------------------------------------- 1 | import pandas 2 | 3 | data_frame = pandas.read_csv('nato_phonetic_alphabet.csv') 4 | 5 | nato_dict = {row.letter: row.code for (index, row) in data_frame.iterrows()} 6 | 7 | while True: 8 | word = input('Enter an word: ').upper() 9 | try: 10 | spelling_word = [nato_dict[letter] for letter in word] 11 | except KeyError: 12 | print("Sorry, only letter in the english alphabet, please.") 13 | else: 14 | break 15 | 16 | print(f'The NATO code for {word} is:') 17 | print(' - '.join(spelling_word)) 18 | -------------------------------------------------------------------------------- /Day030/Lectures/lec01/main.py: -------------------------------------------------------------------------------- 1 | # FileNotFound 2 | # with open('file.txt') as file: 3 | # file.read() 4 | 5 | # KeyError 6 | # dictionary = {"key": "value"} 7 | # value = dictionary["non existent key"] 8 | 9 | # IndexError 10 | # fruits = ["Apple", "Banana", "Pear"] 11 | # fruit = fruits[3] 12 | 13 | # TypeError 14 | # text = "abc" 15 | # print(text + 5) 16 | -------------------------------------------------------------------------------- /Day030/Lectures/lec02/file.txt: -------------------------------------------------------------------------------- 1 | Something 2 | -------------------------------------------------------------------------------- /Day030/Lectures/lec02/main.py: -------------------------------------------------------------------------------- 1 | # FileNotFound 2 | try: 3 | file = open("file.txt") 4 | except: 5 | file = open("file.txt", "w") 6 | file.write("Something\n") 7 | -------------------------------------------------------------------------------- /Day030/Lectures/lec03/file.txt: -------------------------------------------------------------------------------- 1 | Something 2 | -------------------------------------------------------------------------------- /Day030/Lectures/lec03/main.py: -------------------------------------------------------------------------------- 1 | file = None 2 | try: 3 | file = open("file.txt") 4 | dictionary = {"key": "value"} 5 | print(dictionary["key"]) 6 | except FileNotFoundError: 7 | file = open("file.txt", "w") 8 | file.write("Something\n") 9 | except KeyError as error: 10 | print(f"That key {error} not exist.") 11 | else: 12 | print(file.read()) 13 | finally: 14 | print("File was closed") 15 | file.close() 16 | -------------------------------------------------------------------------------- /Day030/Lectures/lec04/file.txt: -------------------------------------------------------------------------------- 1 | Something 2 | -------------------------------------------------------------------------------- /Day030/Lectures/lec04/main.py: -------------------------------------------------------------------------------- 1 | file = None 2 | try: 3 | file = open("file.txt") 4 | dictionary = {"key": "value"} 5 | print(dictionary["key"]) 6 | except FileNotFoundError: 7 | file = open("file.txt", "w") 8 | file.write("Something\n") 9 | except KeyError as error: 10 | print(f"That key {error} not exist.") 11 | else: 12 | print(file.read()) 13 | finally: 14 | print("File was closed") 15 | file.close() 16 | raise TypeError("This is an Error that I made up.") 17 | -------------------------------------------------------------------------------- /Day030/Lectures/lec05.py: -------------------------------------------------------------------------------- 1 | height = float(input("Height: ")) 2 | weight = int(input("Weight: ")) 3 | 4 | if height > 3: 5 | raise ValueError("Human height should not be over 3 meters.") 6 | 7 | bmi = weight / height ** 2 8 | print(bmi) 9 | -------------------------------------------------------------------------------- /Day030/Lectures/lec06/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "Paula": { 3 | "favorite color": "Lilac", 4 | "favorite number": 21 5 | } 6 | } -------------------------------------------------------------------------------- /Day030/Lectures/lec06/main.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | 4 | def write_json(name, fav_color, fav_number): 5 | data = { 6 | name: { 7 | "favorite color": fav_color, 8 | "favorite number": fav_number 9 | } 10 | } 11 | with open("data.json", "w") as file: 12 | json.dump(data, file, indent=4) 13 | 14 | 15 | def read_json(): 16 | with open("data.json") as file: 17 | data = json.load(file) 18 | print(type(data)) 19 | return data 20 | 21 | 22 | def main(): 23 | name = input("Name: ") 24 | fav_color = input("Favorite Color: ") 25 | fav_number = int(input("Favorite Number: ")) 26 | write_json(name, fav_color, fav_number) 27 | print(read_json()) 28 | 29 | 30 | main() 31 | -------------------------------------------------------------------------------- /Day030/Project/padlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day030/Project/padlock.png -------------------------------------------------------------------------------- /Day030/Project/passwords.json: -------------------------------------------------------------------------------- 1 | { 2 | "MyPass": { 3 | "username": "pullynnhah", 4 | "password": "b12fo!z%x88rf!D" 5 | }, 6 | "Amazon": { 7 | "username": "pullynnhah", 8 | "password": "b3rC)i*$*9VkqrX" 9 | }, 10 | "Chocolate": { 11 | "username": "pullynnhah", 12 | "password": "H!ek!CTjZ3Pa45" 13 | }, 14 | "Car": { 15 | "username": "pullynnhah", 16 | "password": "Zvq+8p7&Gdq8X" 17 | }, 18 | "Random": { 19 | "username": "pullynnhah", 20 | "password": "X!)7N8d5XW2GsGh" 21 | }, 22 | "Aol": { 23 | "username": "fake_paula@aol.com", 24 | "password": "2sl#)WN#yE3Il6" 25 | }, 26 | "Yahoo": { 27 | "username": "another_fake_paula@yahoo.com", 28 | "password": "(vtnjQ63(+yt5L" 29 | }, 30 | "Web": { 31 | "username": "pullynnhah", 32 | "password": "a7T46#y$uJ8mToo" 33 | } 34 | } -------------------------------------------------------------------------------- /Day030/Project/project.md: -------------------------------------------------------------------------------- 1 | # Password Manager Improvements 2 | 3 | ## Instructions 4 | 5 | Improve the code of the Password Manager Project in Day029, so it handles exceptions. 6 | Also, add the functionality to search for a password. 7 | 8 | 1. Add a "Search" button next to the website entry field. 9 | 2. Adjust the layout, and the other widgets as needed to get the desired look. 10 | ![](project01.png) 11 | 3. Create a function called `search()` that gets triggered when the "Search" button is pressed. 12 | 4. Check if the user's text entry matches an item in the `data.json`. 13 | 5. If yes, show a messagebox with the website's name and password. 14 | 6. Catch an exception that might occur trying to access the `data.json` showing a messagebox with the text `"No Data File Found"`. 15 | 7. If the user's website does not exist inside `data.json`, show a messagebox that reads: `"No details for the website exists."` 16 | -------------------------------------------------------------------------------- /Day030/Project/project01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day030/Project/project01.png -------------------------------------------------------------------------------- /Day031/Capstone_Project/images/card_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day031/Capstone_Project/images/card_back.png -------------------------------------------------------------------------------- /Day031/Capstone_Project/images/card_front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day031/Capstone_Project/images/card_front.png -------------------------------------------------------------------------------- /Day031/Capstone_Project/images/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day031/Capstone_Project/images/right.png -------------------------------------------------------------------------------- /Day031/Capstone_Project/images/wrong.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day031/Capstone_Project/images/wrong.png -------------------------------------------------------------------------------- /Day031/Capstone_Project/img01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day031/Capstone_Project/img01.png -------------------------------------------------------------------------------- /Day031/Capstone_Project/img02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day031/Capstone_Project/img02.png -------------------------------------------------------------------------------- /Day031/Capstone_Project/img03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day031/Capstone_Project/img03.png -------------------------------------------------------------------------------- /Day031/Capstone_Project/img04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day031/Capstone_Project/img04.gif -------------------------------------------------------------------------------- /Day031/Capstone_Project/img05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day031/Capstone_Project/img05.gif -------------------------------------------------------------------------------- /Day032/Challenges/ch.md: -------------------------------------------------------------------------------- 1 | # Challenge 2 | 3 | # Instructions 4 | Send a motivational quote via email on the current weekday (you can change it to Monday afterwards) 5 | 6 | ## Hits: 7 | 1. Use the `datetime` module to obtain the current day of the week. 8 | 2. Open the [quotes.txt](quotes.txt) file and obtain a list of the quotes. 9 | 3. Use the random 10 | -------------------------------------------------------------------------------- /Day032/Challenges/ch.py: -------------------------------------------------------------------------------- 1 | import smtplib 2 | import random 3 | import os 4 | import datetime as dt 5 | 6 | weekdays = { 7 | "monday": 0, 8 | "tuesday": 1, 9 | "wednesday": 2, 10 | "thursday": 3, 11 | "friday": 4, 12 | "saturday": 5, 13 | "sunday": 6 14 | } 15 | 16 | 17 | def random_quote(): 18 | with open('quotes.txt') as file: 19 | quotes = file.readlines() 20 | return random.choice(quotes) 21 | 22 | 23 | now = dt.datetime.now() 24 | weekday = now.weekday() 25 | check_weekday = input('Enter which day of the week do you want to send an email: ').lower() 26 | 27 | if weekdays[check_weekday] == weekday: 28 | email = os.environ["MY_EMAIL"] 29 | password = os.environ["MY_EMAIL_PASSWORD"] 30 | 31 | with smtplib.SMTP("smtp.gmail.com", port=587) as connection: 32 | connection.starttls() 33 | connection.login(user=email, password=password) 34 | message = f'Subject: Motivational Quote\n\n{random_quote()}' 35 | connection.sendmail(from_addr=email, to_addrs=email, msg=message) 36 | -------------------------------------------------------------------------------- /Day032/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | import smtplib 2 | import os 3 | 4 | email = os.environ["MY_EMAIL"] 5 | password = os.environ["MY_EMAIL_PASSWORD"] 6 | 7 | another_email = "another_fake_paula@yahoo.com" 8 | 9 | connection = smtplib.SMTP("smtp.gmail.com", port=587) 10 | connection.starttls() 11 | connection.login(user=email, password=password) 12 | connection.sendmail(from_addr=email, to_addrs=another_email, msg="Hello!") 13 | connection.close() 14 | -------------------------------------------------------------------------------- /Day032/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | import smtplib 2 | import os 3 | 4 | email = os.environ["MY_EMAIL"] 5 | password = os.environ["MY_EMAIL_PASSWORD"] 6 | another_email = "another_fake_paula@yahoo.com" 7 | 8 | 9 | connection = smtplib.SMTP("smtp.gmail.com", port=587) 10 | connection.starttls() 11 | connection.login(user=email, password=password) 12 | message = "Subject:Hello World\n\nSending e-mail with Python!!!" 13 | connection.sendmail(from_addr=email, to_addrs=another_email, msg=message) 14 | connection.close() 15 | -------------------------------------------------------------------------------- /Day032/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | import smtplib 2 | import os 3 | 4 | email = os.environ["MY_EMAIL"] 5 | password = os.environ["MY_EMAIL_PASSWORD"] 6 | another_email = "another_fake_paula@yahoo.com" 7 | 8 | with smtplib.SMTP("smtp.gmail.com", port=587) as connection: 9 | connection.starttls() 10 | connection.login(user=email, password=password) 11 | message = "Subject:Hello World\n\nSending e-mail with Python!!!" 12 | connection.sendmail(from_addr=email, to_addrs=another_email, msg=message) 13 | -------------------------------------------------------------------------------- /Day032/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | import datetime as dt 2 | 3 | now = dt.datetime.now() 4 | print(now) 5 | print(type(now)) 6 | print() 7 | 8 | year = now.year 9 | weekday = now.weekday() 10 | print(year) 11 | print(weekday) 12 | print() 13 | 14 | date_of_birth = dt.datetime(year=1996, month=6, day=21, hour=7, minute=20) 15 | print(date_of_birth) 16 | -------------------------------------------------------------------------------- /Day032/Project/birthdays.csv: -------------------------------------------------------------------------------- 1 | name,email,year,month,day 2 | Fake Paula,fake_paula@aol.com,2020,12,18 3 | Another Fake Paula,another_fake_paula@yahoo.com,2020,12,18 4 | Paula,pullynnah@icloud.com,1996,6,21 5 | -------------------------------------------------------------------------------- /Day032/Project/letter_templates/letter_1.txt: -------------------------------------------------------------------------------- 1 | Dear [NAME], 2 | 3 | Happy birthday! 4 | 5 | All the best for the year! 6 | 7 | Paula 8 | -------------------------------------------------------------------------------- /Day032/Project/letter_templates/letter_2.txt: -------------------------------------------------------------------------------- 1 | Hey [NAME], 2 | 3 | Happy birthday! Have a wonderful time today and eat lots of cake! 4 | 5 | Lots of love, 6 | 7 | Paula 8 | -------------------------------------------------------------------------------- /Day032/Project/letter_templates/letter_3.txt: -------------------------------------------------------------------------------- 1 | Dear [NAME], 2 | 3 | It's your birthday! Have a great day! 4 | 5 | All my love, 6 | 7 | Paula 8 | -------------------------------------------------------------------------------- /Day032/Project/project.md: -------------------------------------------------------------------------------- 1 | # Automated Birthday Wisher 2 | 3 | ## Extra Hard Starting Project 4 | 5 | 1. Update the birthdays.csv 6 | 7 | 2. Check if today matches a birthday in the birthdays.csv 8 | 9 | 3. If step 2 is true, pick a random letter from letter templates and replace the [NAME] with the person's actual name from birthdays.csv 10 | 11 | 4. Send the letter generated in step 3 to that person's email address. 12 | -------------------------------------------------------------------------------- /Day033/Challenges/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day033/Challenges/background.png -------------------------------------------------------------------------------- /Day033/Challenges/ch.md: -------------------------------------------------------------------------------- 1 | # Challenge 2 | 3 | ## Instructions 4 | 1. Make a get() request to the [Kanye Rest API](https://api.kanye.rest). 5 | 2. Raise an exception if the request returned an unsuccessful status code. 6 | 3. Parse the JSON to obtain the quote text. 7 | 4. Display the quote in the canvas `quote` widget. 8 | -------------------------------------------------------------------------------- /Day033/Challenges/ch.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | import requests 3 | 4 | FONT = ("Letters for Learners", 30, "bold") 5 | 6 | 7 | def get_quote(): 8 | response = requests.get("https://api.kanye.rest") 9 | response.raise_for_status() 10 | text = response.json()["quote"] 11 | canvas.itemconfig(quote, text=text) 12 | 13 | 14 | window = Tk() 15 | window.title("Kanye Says...") 16 | window.config(padx=50, pady=50) 17 | 18 | canvas = Canvas(width=300, height=414) 19 | background_img = PhotoImage(file="background.png") 20 | canvas.create_image(150, 207, image=background_img) 21 | quote = canvas.create_text(150, 207, text="Kanye Quote goes HERE", 22 | width=250, font=FONT, fill="white") 23 | canvas.grid(row=0, column=0) 24 | 25 | kanye_img = PhotoImage(file="kanye.png") 26 | kanye_button = Button(image=kanye_img, highlightthickness=0, command=get_quote) 27 | kanye_button.grid(row=1, column=0) 28 | 29 | window.mainloop() 30 | -------------------------------------------------------------------------------- /Day033/Challenges/kanye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day033/Challenges/kanye.png -------------------------------------------------------------------------------- /Day033/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | response = requests.get(url="http://api.open-notify.org/iss-now.json") 4 | print(response) 5 | print(response.status_code) 6 | print() 7 | 8 | response = requests.get(url="http://api.open-notify.org/is-now.json") 9 | print(response) 10 | print(response.status_code) 11 | -------------------------------------------------------------------------------- /Day033/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | response = requests.get(url="http://api.open-notify.org/iss-now.json") 4 | 5 | if response.status_code != 200: 6 | print("Error") 7 | else: 8 | print("No Error") 9 | print() 10 | 11 | response = requests.get(url="http://api.open-notify.org/is-now.json") 12 | 13 | if response.status_code != 200: 14 | print("Error") 15 | else: 16 | print("No Error") 17 | -------------------------------------------------------------------------------- /Day033/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | response = requests.get(url="http://api.open-notify.org/iss-now.json") 4 | 5 | if response.status_code != 200: 6 | raise Exception("Bad response from ISS API.") 7 | else: 8 | print("Response worked") 9 | response = requests.get(url="http://api.open-notify.org/is-now.json") 10 | 11 | if response.status_code != 200: 12 | raise Exception("Bad response from ISS API.") 13 | else: 14 | print("Response worked") 15 | -------------------------------------------------------------------------------- /Day033/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | response = requests.get(url="http://api.open-notify.org/iss-now.json") 4 | 5 | if response.status_code == 404: 6 | raise Exception("That resource does not exist.") 7 | elif response.status_code == 401: 8 | raise Exception("You are not authorised to access this data.") 9 | -------------------------------------------------------------------------------- /Day033/Lectures/lec05.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | response = requests.get(url="http://api.open-notify.org/iss-now.json") 4 | response.raise_for_status() 5 | response = requests.get(url="http://api.open-notify.org/is-now.json") 6 | response.raise_for_status() 7 | -------------------------------------------------------------------------------- /Day033/Lectures/lec06.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | response = requests.get(url="http://api.open-notify.org/iss-now.json") 4 | response.raise_for_status() 5 | 6 | data = response.json() 7 | print(data) 8 | print(data["iss_position"]) 9 | 10 | longitude = data["iss_position"]["longitude"] 11 | latitude = data["iss_position"]["latitude"] 12 | iss_position = (longitude, latitude) 13 | print(longitude) 14 | print(latitude) 15 | print(iss_position) 16 | -------------------------------------------------------------------------------- /Day033/Lectures/lec07.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from datetime import datetime 3 | 4 | LATITUDE = -22.338930 5 | LONGITUDE = -49.055190 6 | URL = "https://api.sunrise-sunset.org/json" 7 | 8 | 9 | def hour_time(time): 10 | return int(time.split("T")[1].split(':')[0]) 11 | 12 | parameters = { 13 | 'lat': LATITUDE, 14 | 'lng': LONGITUDE, 15 | 'formatted': 0 16 | } 17 | 18 | response = requests.get(URL, params=parameters) 19 | response.raise_for_status() 20 | 21 | data = response.json() 22 | print(data) 23 | print() 24 | 25 | 26 | sunrise = data["results"]["sunrise"] 27 | sunset = data["results"]["sunset"] 28 | print(sunrise) 29 | print(sunset) 30 | print() 31 | 32 | time_now = datetime.now() 33 | print(time_now) 34 | print() 35 | 36 | sunrise_hour = hour_time(sunrise) 37 | sunset_hour = hour_time(sunset) 38 | now_hour = time_now.hour 39 | 40 | if sunrise_hour <= now_hour <= sunset_hour: 41 | print("It's day time!") 42 | else: 43 | print("It's night time!") 44 | -------------------------------------------------------------------------------- /Day033/Project/project.md: -------------------------------------------------------------------------------- 1 | # ISS Overhead Notifier 2 | 3 | # Instructions 4 | 5 | 6 | Your position is within +5 or -5 degrees of the ISS position. 7 | 8 | If the ISS is close to my current position, and it is currently dark. Then, send me an email to tell me to look up. 9 | 10 | **BONUS:** run the code every 60 seconds. 11 | -------------------------------------------------------------------------------- /Day034/Lectures/lec.py: -------------------------------------------------------------------------------- 1 | age: int 2 | name: str 3 | height: float 4 | is_human: bool 5 | 6 | age = 24 7 | name = "Paula" 8 | height = 1.62 9 | is_human = True 10 | 11 | print(age, name, height, is_human) 12 | 13 | 14 | def police_check(person_age: int) -> bool: 15 | return person_age > 18 16 | 17 | 18 | age = int(input("Your age: ")) 19 | if police_check(age): 20 | print("You may pass") 21 | else: 22 | print("Pay a fine.") 23 | -------------------------------------------------------------------------------- /Day034/Project/data.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | params = { 4 | "amount": 10, 5 | "type": "boolean" 6 | } 7 | 8 | url = "https://opentdb.com/api.php" 9 | 10 | response = requests.get(url=url, params=params) 11 | response.raise_for_status() 12 | question_data = response.json()['results'] 13 | -------------------------------------------------------------------------------- /Day034/Project/images/false.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day034/Project/images/false.png -------------------------------------------------------------------------------- /Day034/Project/images/true.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day034/Project/images/true.png -------------------------------------------------------------------------------- /Day034/Project/project.md: -------------------------------------------------------------------------------- 1 | # Project name 2 | 3 | # Instructions 4 | 1. Change the `data.py` file, so it gets 10 questions from the API [Trivia Database]() 5 | 6 | 2. Unescape the HTML entities, so the questions are more readable. To do that make changes 7 | on`quiz_brain.py` file. 8 | 9 | ```python 10 | import html 11 | 12 | html_text = "Some HTML code" 13 | questions = html.unescape(html_text) 14 | ``` 15 | 16 | 3. Create the `QuizInterface` class in the `ui.py` file. Use the image below as a guider. 17 | ![](ui.png) 18 | 19 | 4. Change the `QuizBrain` class, so that the method `next_question()` returns a string 20 | with the question to be asked instead of inputting it, in the console. 21 | 22 | 5. Create two new methods that you can add as a command to the buttons. The methods need to call `check_answer()` from the `quiz` and pass over the string "True" or "False". This should print some feedback to the console. 23 | 24 | 6. Change the canvas' background colour to green if the `is_correct` is True, and change it to red if it is False. 25 | 26 | 7. When a button has been pressed display the next question after 1000 milliseconds, but make sure to change the background back to white. 27 | -------------------------------------------------------------------------------- /Day034/Project/project.py: -------------------------------------------------------------------------------- 1 | from question_model import Question 2 | from data import question_data 3 | from quiz_brain import QuizBrain 4 | from ui import QuizInterface 5 | 6 | question_bank = [] 7 | for question in question_data: 8 | question_text = question["question"] 9 | question_answer = question["correct_answer"] 10 | new_question = Question(question_text, question_answer) 11 | question_bank.append(new_question) 12 | 13 | 14 | quiz = QuizBrain(question_bank) 15 | quiz_ui = QuizInterface(quiz) 16 | 17 | # while quiz.still_has_questions(): 18 | # quiz.next_question() 19 | 20 | print("You've completed the quiz") 21 | print(f"Your final score was: {quiz.score}/{quiz.question_number}") 22 | -------------------------------------------------------------------------------- /Day034/Project/question_model.py: -------------------------------------------------------------------------------- 1 | class Question: 2 | 3 | def __init__(self, q_text, q_answer): 4 | self.text = q_text 5 | self.answer = q_answer 6 | -------------------------------------------------------------------------------- /Day034/Project/quiz_brain.py: -------------------------------------------------------------------------------- 1 | import html 2 | 3 | 4 | class QuizBrain: 5 | 6 | def __init__(self, q_list): 7 | self.question_number = 0 8 | self.score = 0 9 | self.question_list = q_list 10 | self.current_question = None 11 | 12 | def still_has_questions(self): 13 | return self.question_number < len(self.question_list) 14 | 15 | def next_question(self): 16 | self.current_question = self.question_list[self.question_number] 17 | self.question_number += 1 18 | question = html.unescape(self.current_question.text) 19 | return f"Q.{self.question_number}: {question}" 20 | 21 | def check_answer(self, user_answer): 22 | correct_answer = self.current_question.answer 23 | test = user_answer.lower() == correct_answer.lower() 24 | if test: 25 | self.score += 1 26 | return test 27 | -------------------------------------------------------------------------------- /Day034/Project/ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day034/Project/ui.png -------------------------------------------------------------------------------- /Day035/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import os 3 | 4 | LATITUDE = -22.338930 5 | LONGITUDE = -49.055190 6 | 7 | api_key = os.environ["OWM_API_KEY"] 8 | api_url = "https://api.openweathermap.org/data/2.5/onecall" 9 | params = { 10 | "lat": LATITUDE, 11 | "lon": LONGITUDE, 12 | "appid": api_key 13 | } 14 | 15 | response = requests.get(api_url, params=params) 16 | 17 | data = response.json() 18 | print(data) 19 | -------------------------------------------------------------------------------- /Day035/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import os 3 | 4 | LATITUDE = -22.338930 5 | LONGITUDE = -49.055190 6 | 7 | api_key = os.environ["OWM_API_KEY"] 8 | api_url = "https://api.openweathermap.org/data/2.5/onecall" 9 | params = { 10 | "lat": LATITUDE, 11 | "lon": LONGITUDE, 12 | "exclude": "current,minutely,daily,alerts", 13 | "appid": api_key 14 | } 15 | 16 | response = requests.get(api_url, params=params) 17 | response.raise_for_status() 18 | 19 | data = response.json() 20 | 21 | for hourly_data in data["hourly"][:12]: 22 | condition_code = hourly_data["weather"][0]["id"] 23 | if condition_code < 700: 24 | print("Bring an umbrella.") 25 | break 26 | -------------------------------------------------------------------------------- /Day035/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | from twilio.rest import Client 2 | import os 3 | 4 | account_sid = os.environ["TWILIO_SID"] 5 | auth_token = os.environ["TWILIO_TOKEN"] 6 | client = Client(account_sid, auth_token) 7 | 8 | twilio_number = os.environ["TWILIO_NUMBER"] 9 | my_number = os.environ["MY_NUMBER"] 10 | 11 | message = client.messages.create( 12 | body="This message was send from Python!!!", 13 | from_=twilio_number, 14 | to=my_number 15 | ) 16 | 17 | print(message.status) 18 | -------------------------------------------------------------------------------- /Day035/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import os 3 | from twilio.rest import Client 4 | 5 | account_sid = os.environ.get("TWILIO_SID") 6 | auth_token = os.environ.get("TWILIO_TOKEN") 7 | client = Client(account_sid, auth_token) 8 | twilio_number = os.environ.get("TWILIO_NUMBER") 9 | my_number = os.environ.get("MY_NUMBER") 10 | 11 | LATITUDE = -22.338930 12 | LONGITUDE = -49.055190 13 | 14 | api_key = os.environ.get("OWM_API_KEY") 15 | api_url = "https://api.openweathermap.org/data/2.5/onecall" 16 | params = { 17 | "lat": LATITUDE, 18 | "lon": LONGITUDE, 19 | "exclude": "current,minutely,daily,alerts", 20 | "appid": api_key 21 | } 22 | 23 | response = requests.get(api_url, params=params) 24 | response.raise_for_status() 25 | 26 | data = response.json() 27 | 28 | for hourly_data in data["hourly"][:12]: 29 | condition_code = hourly_data["weather"][0]["id"] 30 | if condition_code < 700: 31 | message = client.messages.create( 32 | body="It's gonna rain! Don't forget to bring an ☔", 33 | from_=twilio_number, 34 | to=my_number 35 | ) 36 | break 37 | -------------------------------------------------------------------------------- /Day035/Project/project.md: -------------------------------------------------------------------------------- 1 | # Weather Automatic SMS Sender 2 | 3 | ## Instructions 4 | 5 | Join the codes from lec02.py and lec03.py and create a notification alerter for when it rains. 6 | -------------------------------------------------------------------------------- /Day035/Project/project.py: -------------------------------------------------------------------------------- 1 | import os 2 | import requests 3 | from twilio.rest import Client 4 | 5 | account_sid = os.environ["TWILIO_SID"] 6 | auth_token = os.environ["TWILIO_TOKEN"] 7 | client = Client(account_sid, auth_token) 8 | 9 | twilio_number = os.environ["TWILIO_NUMBER"] 10 | my_number = os.environ["MY_NUMBER"] 11 | 12 | LATITUDE = -22.338930 13 | LONGITUDE = -49.055190 14 | 15 | api_key = os.environ["OWM_API_KEY"] 16 | api_url = "https://api.openweathermap.org/data/2.5/onecall" 17 | params = { 18 | "lat": LATITUDE, 19 | "lon": LONGITUDE, 20 | "exclude": "current,minutely,daily,alerts", 21 | "appid": api_key 22 | } 23 | 24 | response = requests.get(api_url, params=params) 25 | response.raise_for_status() 26 | 27 | data = response.json() 28 | 29 | for hourly_data in data["hourly"][:12]: 30 | condition_code = hourly_data["weather"][0]["id"] 31 | if condition_code < 700: 32 | message = client.messages.create( 33 | body="It's gonna rain! Don't forget to bring an ☔", 34 | from_=twilio_number, 35 | to=my_number 36 | ) 37 | break 38 | -------------------------------------------------------------------------------- /Day037/Challenges/ch.md: -------------------------------------------------------------------------------- 1 | # Challenge 2 | 3 | ## Instructions 4 | 5 | Add a pixel to pixela. 6 | -------------------------------------------------------------------------------- /Day037/Challenges/ch.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from os import environ 3 | 4 | USERNAME = "pullynnhah" 5 | TOKEN = environ["PIXELA_TOKEN"] 6 | GRAPH_ID = "graph" 7 | pixel_endpoint = f"https://pixe.la/v1/users/{USERNAME}/graphs/{GRAPH_ID}" 8 | 9 | pixel_config = { 10 | "date": "20201220", 11 | "quantity": "2" 12 | } 13 | 14 | headers = { 15 | "X-USER-TOKEN": TOKEN 16 | } 17 | 18 | response = requests.post(url=pixel_endpoint, json=pixel_config, headers=headers) 19 | print(response.text) 20 | -------------------------------------------------------------------------------- /Day037/Lectures/lec01.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from os import environ 3 | pixela_endpoint = "https://pixe.la/v1/users" 4 | 5 | user_params = { 6 | "token": environ["PIXELA_TOKEN"], 7 | "username": "pullynnhah", 8 | "agreeTermsOfService": "yes", 9 | "notMinor": "yes" 10 | } 11 | response = requests.post(url=pixela_endpoint, json=user_params) 12 | print(response.text) 13 | -------------------------------------------------------------------------------- /Day037/Lectures/lec02.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from os import environ 3 | 4 | USERNAME = "pullynnhah" 5 | TOKEN = environ["PIXELA_TOKEN"] 6 | graph_endpoint = f"https://pixe.la/v1/users/{USERNAME}/graphs" 7 | 8 | graph_config = { 9 | "id": "graph", 10 | "name": "100 Days Of Code", 11 | "unit": "days", 12 | "type": "int", 13 | "color": "ajisai" 14 | } 15 | 16 | headers = { 17 | "X-USER-TOKEN": TOKEN 18 | } 19 | 20 | response = requests.post(url=graph_endpoint, json=graph_config, headers=headers) 21 | print(response.text) 22 | -------------------------------------------------------------------------------- /Day037/Lectures/lec03.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import sys 3 | from os import environ 4 | from datetime import datetime 5 | 6 | USERNAME = "pullynnhah" 7 | TOKEN = environ["PIXELA_TOKEN"] 8 | GRAPH_ID = "graph" 9 | pixel_endpoint = f"https://pixe.la/v1/users/{USERNAME}/graphs/{GRAPH_ID}" 10 | 11 | today = datetime.now() 12 | quantity = input("How many days did you complete today? ") 13 | 14 | pixel_config = { 15 | "date": today.strftime("%Y%m%d"), 16 | "quantity": quantity 17 | } 18 | 19 | headers = { 20 | "X-USER-TOKEN": TOKEN 21 | } 22 | 23 | response = requests.post(url=pixel_endpoint, json=pixel_config, headers=headers) 24 | print(response.text) 25 | -------------------------------------------------------------------------------- /Day037/Lectures/lec04.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from os import environ 3 | 4 | USERNAME = "pullynnhah" 5 | TOKEN = environ["PIXELA_TOKEN"] 6 | GRAPH_ID = "graph" 7 | update_endpoint = f"https://pixe.la/v1/users/{USERNAME}/graphs/{GRAPH_ID}/20201220" 8 | 9 | pixel_config = { 10 | "date": "20201220", 11 | "quantity": "3" 12 | } 13 | 14 | headers = { 15 | "X-USER-TOKEN": TOKEN 16 | } 17 | 18 | response = requests.put(url=update_endpoint, json=pixel_config, headers=headers) 19 | print(response.text) 20 | -------------------------------------------------------------------------------- /Day037/Lectures/lec05.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from os import environ 3 | 4 | USERNAME = "pullynnhah" 5 | TOKEN = environ["PIXELA_TOKEN"] 6 | GRAPH_ID = "graph" 7 | delete_endpoint = f"https://pixe.la/v1/users/{USERNAME}/graphs/{GRAPH_ID}/20201220" 8 | 9 | 10 | headers = { 11 | "X-USER-TOKEN": TOKEN 12 | } 13 | 14 | response = requests.delete(url=delete_endpoint, headers=headers) 15 | print(response.text) 16 | -------------------------------------------------------------------------------- /Day038/Challenge_Project/project01.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import requests 4 | import json 5 | 6 | API_ID = os.environ['NUTRITIONIX_API_ID'] 7 | API_KEY = os.environ['NUTRITIONIX_API_KEY'] 8 | END_POINT = ' https://trackapi.nutritionix.com/v2/natural/exercise' 9 | GENDER = "female" 10 | WEIGHT_KG = 72.3 11 | HEIGHT_CM = 162 12 | AGE = 24 13 | 14 | headers = { 15 | 'x-app-id': API_ID, 16 | 'x-app-key': API_KEY 17 | } 18 | 19 | params = { 20 | 'query': input('Tell me which exercise you did: '), 21 | "gender": GENDER, 22 | "weight_kg": WEIGHT_KG, 23 | "height_cm": HEIGHT_CM, 24 | "age": AGE 25 | } 26 | 27 | response = requests.post(url=END_POINT, json=params, headers=headers) 28 | print(response.json()) 29 | -------------------------------------------------------------------------------- /Day038/Challenge_Project/step04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day038/Challenge_Project/step04.png -------------------------------------------------------------------------------- /Day039/Capstone_Project/data_manager.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import requests 4 | 5 | SHEET = 'price' 6 | ENDPOINT = 'https://api.sheety.co/0599c004d034001f75a8249650a83978/flightDeals/prices' 7 | TOKEN = os.environ['SHEETY_TOKEN'] 8 | 9 | 10 | class DataManager: 11 | def __init__(self, endpoint, sheet, token): 12 | self.sheet = sheet 13 | self.endpoint = endpoint 14 | self.headers = {"Authorization": f'Bearer {token}'} 15 | self.data = self._get_data() 16 | 17 | def _get_data(self): 18 | response = requests.get(self.endpoint, headers=self.headers) 19 | return response.json() 20 | 21 | def put_data(self, data): 22 | row = data.pop('id') 23 | requests.put(f'{self.endpoint}/{row}', 24 | json=self._gen_data(**data), 25 | headers=self.headers) 26 | self.data = self._get_data() 27 | 28 | def _gen_data(self, **kwargs): 29 | return { 30 | self.sheet: kwargs 31 | } 32 | 33 | def get_iata_codes(self): 34 | return [row['iataCode'] for row in self.data] 35 | 36 | def get_lowest_prices(self): 37 | return [row['lowestPrice'] for row in self.data] 38 | -------------------------------------------------------------------------------- /Day039/Capstone_Project/flight_data.py: -------------------------------------------------------------------------------- 1 | class FlightData: 2 | def __init__(self, flight): 3 | self.data = flight[0] 4 | self.formatted_data = self._format_data() 5 | 6 | def _format_data(self): 7 | return { 8 | 'destiny': self.data['cityTo'], 9 | 'from': f'{self.data["cityFrom"]}-{self.data["flyFrom"]}', 10 | 'to': f'{self.data["cityTo"]}-{self.data["flyTo"]}', 11 | 'price': self.data['price'], 12 | 'departure_date': self.data['route'][0]["local_departure"].split('T')[0], 13 | 'arrival_date': self.data['route'][1]["local_departure"].split('T')[0] 14 | } 15 | -------------------------------------------------------------------------------- /Day039/Capstone_Project/flight_search.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import requests 4 | 5 | ENDPOINT = 'https://tequila-api.kiwi.com' 6 | API_LOCATIONS = '/locations/query' 7 | API_SEARCH = '/v2/search' 8 | API_KEY = os.environ['TEQUILA_API_KEY'] 9 | AFFILL_ID = os.environ['TEQUILA_AFFILL_ID'] 10 | 11 | 12 | class FlightSearch: 13 | def __init__(self, api_call, endpoint, params): 14 | self.endpoint = f'{endpoint}{api_call}' 15 | self.params = params 16 | self.data = self._get_data() 17 | 18 | def _get_data(self): 19 | response = requests.get(self.endpoint, self.params) 20 | return response.json() 21 | 22 | def search_locations(self, key, value, city): 23 | for location in self.data['locations']: 24 | if location[key] == value: 25 | return location[city] 26 | -------------------------------------------------------------------------------- /Day039/Capstone_Project/notification_manager.py: -------------------------------------------------------------------------------- 1 | import os 2 | from twilio.rest import Client 3 | 4 | ACCOUNT_SID = os.environ["TWILIO_SID"] 5 | AUTH_TOKEN = os.environ["TWILIO_TOKEN"] 6 | 7 | TWILIO_NUMBER = os.environ["TWILIO_NUMBER"] 8 | MY_NUMBER = os.environ["MY_NUMBER"] 9 | 10 | 11 | class NotificationManager: 12 | def __init__(self, sid, token): 13 | self.client = Client(sid, token) 14 | 15 | def send_message(self, from_number, to_number, message): 16 | self.client.messages.create(body=message, from_=from_number, to=to_number) 17 | -------------------------------------------------------------------------------- /Day040/Capstone_Project/add_members.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import requests 4 | 5 | ENDPOINT = 'https://api.sheety.co/0599c004d034001f75a8249650a83978/flightDeals/users' 6 | TOKEN = os.environ['SHEETY_TOKEN'] 7 | 8 | print("Welcome to Paula's Flight Club.") 9 | print('We find the best flight deals and mail you.') 10 | first_name = input('What is your first name? ').title() 11 | last_name = input('What is your last name? ').title() 12 | while True: 13 | email = input('What is your email? ').lower() 14 | email_verification = input('Please, reenter your email: ').lower() 15 | if email == email_verification: 16 | break 17 | 18 | users = {'user': dict(firstName=first_name, lastName=last_name, email=email)} 19 | headers = dict(Authorization=f'Bearer {TOKEN}') 20 | requests.post(url=ENDPOINT, json=users, headers=headers) 21 | 22 | print("You're in the club!") 23 | -------------------------------------------------------------------------------- /Day040/Capstone_Project/data_manager.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import requests 4 | 5 | SHEET = 'price' 6 | ENDPOINT = 'https://api.sheety.co/0599c004d034001f75a8249650a83978/flightDeals' 7 | TOKEN = os.environ['SHEETY_TOKEN'] 8 | USERS_SHEET = 'user' 9 | 10 | 11 | class DataManager: 12 | def __init__(self, endpoint, sheet, token): 13 | self.sheet = sheet 14 | self.endpoint = f'{endpoint}/{sheet}s' 15 | self.headers = {"Authorization": f'Bearer {token}'} 16 | self.data = self._get_data() 17 | 18 | def _get_data(self): 19 | response = requests.get(self.endpoint, headers=self.headers) 20 | return response.json() 21 | 22 | def put_data(self, data): 23 | row = data.pop('id') 24 | requests.put(f'{self.endpoint}/{row}', 25 | json=self._gen_data(**data), 26 | headers=self.headers) 27 | self.data = self._get_data() 28 | 29 | def _gen_data(self, **kwargs): 30 | return { 31 | self.sheet: kwargs 32 | } 33 | 34 | def get_iata_codes(self): 35 | return [row['iataCode'] for row in self.data] 36 | 37 | def get_lowest_prices(self): 38 | return [row['lowestPrice'] for row in self.data] 39 | -------------------------------------------------------------------------------- /Day040/Capstone_Project/flight_data.py: -------------------------------------------------------------------------------- 1 | class FlightData: 2 | def __init__(self, flight): 3 | self.data = flight[0] 4 | self.formatted_data = self._format_data() 5 | 6 | def _format_data(self): 7 | try: 8 | return_date = self.data['route'][2]["local_departure"].split('T')[0] 9 | except IndexError: 10 | return_date = self.data['route'][1]["local_departure"].split('T')[0] 11 | return { 12 | 'destiny': self.data['cityTo'], 13 | 'from': f'{self.data["cityFrom"]}-{self.data["flyFrom"]}', 14 | 'to': f'{self.data["cityTo"]}-{self.data["flyTo"]}', 15 | 'price': self.data['price'], 16 | 'departure_date': self.data['route'][0]["local_departure"].split('T')[0], 17 | 'arrival_date': return_date, 18 | 'via_city': self.data['route'][0]['cityTo'] 19 | } 20 | -------------------------------------------------------------------------------- /Day040/Capstone_Project/flight_search.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import requests 4 | 5 | ENDPOINT = 'https://tequila-api.kiwi.com' 6 | API_LOCATIONS = '/locations/query' 7 | API_SEARCH = '/v2/search' 8 | API_KEY = os.environ['TEQUILA_API_KEY'] 9 | AFFILL_ID = os.environ['TEQUILA_AFFILL_ID'] 10 | 11 | 12 | class FlightSearch: 13 | def __init__(self, api_call, endpoint, params): 14 | self.endpoint = f'{endpoint}{api_call}' 15 | self.params = params 16 | self.data = self._get_data() 17 | 18 | def _get_data(self): 19 | response = requests.get(self.endpoint, self.params) 20 | return response.json() 21 | 22 | def search_locations(self, key, value, city): 23 | for location in self.data['locations']: 24 | if location[key] == value: 25 | return location[city] 26 | -------------------------------------------------------------------------------- /Day040/Capstone_Project/notification_manager.py: -------------------------------------------------------------------------------- 1 | import os 2 | import smtplib 3 | from twilio.rest import Client 4 | 5 | ACCOUNT_SID = os.environ["TWILIO_SID"] 6 | AUTH_TOKEN = os.environ["TWILIO_TOKEN"] 7 | 8 | TWILIO_NUMBER = os.environ["TWILIO_NUMBER"] 9 | MY_NUMBER = os.environ["MY_NUMBER"] 10 | 11 | EMAIL = os.environ["MY_EMAIL"] 12 | PASSWORD = os.environ["MY_EMAIL_PASSWORD"] 13 | 14 | 15 | class NotificationManager: 16 | def __init__(self, email=None, password=None): 17 | self.client = None 18 | self.email = email 19 | self.password = password 20 | 21 | def send_message(self, from_number, to_number, message, sid, token): 22 | self.client = Client(sid, token) 23 | self.client.messages.create(body=message, from_=from_number, to=to_number) 24 | 25 | def send_email(self, message, *emails): 26 | emails = ', '.join(emails) 27 | with smtplib.SMTP("smtp.gmail.com", port=587) as connection: 28 | connection.starttls() 29 | connection.login(user=self.email, password=self.password) 30 | connection.sendmail(from_addr=self.email, to_addrs=emails, msg=message) 31 | -------------------------------------------------------------------------------- /Day040/Capstone_Project/step01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day040/Capstone_Project/step01.png -------------------------------------------------------------------------------- /Day040/Capstone_Project/step04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day040/Capstone_Project/step04.png -------------------------------------------------------------------------------- /Day040/Capstone_Project/text.py: -------------------------------------------------------------------------------- 1 | flight_params = { 2 | 'apikey': 'API', 3 | 'fly_from': 'LON', 4 | 'date_from': 'tomorrow', 5 | 'date_to': 'future_date', 6 | 'nights_in_dst_from': 7, 7 | 'nights_in_dst_to': 28, 8 | 'flight_type': 'round', 9 | 'one_for_city': 1, 10 | 'adults': 1, 11 | 'curr': 'GBP' 12 | } 13 | flight_params.update(fly_to='LAX', max_stopovers=0) 14 | print(flight_params) 15 | -------------------------------------------------------------------------------- /Day041/Lectures/lec01.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

THE ADVENTURES OF
SHERLOCK HOLMES

5 |
6 |

by

7 |
8 |

Arthur Conan Doyle

9 |
10 |
11 | -------------------------------------------------------------------------------- /Day041/Project/contact_info.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Paula's Contact Info 6 | 7 | 8 |

Paula's Contact Information

9 |

To get in touch with me, please use one of the following:

10 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Day041/Project/paula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day041/Project/paula.png -------------------------------------------------------------------------------- /Day042/Challenges/ch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | HTML Inputs 6 | 7 | 8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /Day042/Lectures/lec02.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Lecture 2 6 | 7 | 8 |
9 | 10 |
11 | 12 |
13 | 14 |
15 | 16 |
17 | 18 | 19 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /Day042/Project/contact_info.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Paula's Contact Info 6 | 7 | 8 |

Paula's Contact Information

9 |

To get in touch with me, please use one of the following:

10 | 17 |

Alternatively you could just send your message right here:

18 | 19 |
20 | 21 |
22 | 23 |
24 |
25 |
26 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /Day042/Project/paula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day042/Project/paula.png -------------------------------------------------------------------------------- /Day043/Challenges/ch01/css/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: lightpink; 3 | } 4 | hr { 5 | border-style: none; 6 | border-top-style: dotted; 7 | border-color: white; 8 | border-width: 5px; 9 | width: 5%; 10 | } 11 | h1 { 12 | color: hotpink; 13 | } 14 | 15 | h3 { 16 | color: hotpink; 17 | } 18 | -------------------------------------------------------------------------------- /Day043/Challenges/ch01/paula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day043/Challenges/ch01/paula.png -------------------------------------------------------------------------------- /Day043/Challenges/ch02/css/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: lightpink; 3 | } 4 | hr { 5 | border-style: none; 6 | border-top-style: dotted; 7 | border-color: white; 8 | border-width: 5px; 9 | width: 5%; 10 | } 11 | h1 { 12 | color: hotpink; 13 | } 14 | 15 | h3 { 16 | color: hotpink; 17 | } 18 | -------------------------------------------------------------------------------- /Day043/Challenges/ch02/paula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day043/Challenges/ch02/paula.png -------------------------------------------------------------------------------- /Day043/Lectures/lec01/contact_info.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Paula's Contact Info 6 | 7 | 8 |

Paula's Contact Information

9 |

To get in touch with me, please use one of the following:

10 | 17 |

Alternatively you could just send your message right here:

18 | 19 |
20 | 21 |
22 | 23 |
24 |
25 |
26 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /Day043/Lectures/lec01/paula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day043/Lectures/lec01/paula.png -------------------------------------------------------------------------------- /Day043/Lectures/lec02/contact_info.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Paula's Contact Info 6 | 7 | 8 |

Paula's Contact Information

9 |

To get in touch with me, please use one of the following:

10 | 17 |

Alternatively you could just send your message right here:

18 | 19 |
20 | 21 |
22 | 23 |
24 |
25 |
26 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /Day043/Lectures/lec02/paula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day043/Lectures/lec02/paula.png -------------------------------------------------------------------------------- /Day043/Lectures/lec03/contact_info.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Paula's Contact Info 6 | 7 | 8 |

Paula's Contact Information

9 |

To get in touch with me, please use one of the following:

10 | 17 |

Alternatively you could just send your message right here:

18 | 19 |
20 | 21 |
22 | 23 |
24 |
25 |
26 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /Day043/Lectures/lec03/paula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day043/Lectures/lec03/paula.png -------------------------------------------------------------------------------- /Day043/Lectures/lec04/contact_info.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Paula's Contact Info 6 | 7 | 8 |

Paula's Contact Information

9 |

To get in touch with me, please use one of the following:

10 | 17 |

Alternatively you could just send your message right here:

18 | 19 |
20 | 21 |
22 | 23 |
24 |
25 |
26 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /Day043/Lectures/lec04/paula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day043/Lectures/lec04/paula.png -------------------------------------------------------------------------------- /Day043/Lectures/lec05/contact_info.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Paula's Contact Info 6 | 7 | 8 |

Paula's Contact Information

9 |

To get in touch with me, please use one of the following:

10 | 17 |

Alternatively you could just send your message right here:

18 | 19 |
20 | 21 |
22 | 23 |
24 |
25 |
26 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /Day043/Lectures/lec05/paula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day043/Lectures/lec05/paula.png -------------------------------------------------------------------------------- /Day043/Lectures/lec06/css/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: lightpink; 3 | } 4 | hr { 5 | border-style: none; 6 | border-top-style: dotted; 7 | border-color: white; 8 | border-width: 5px; 9 | width: 5%; 10 | } 11 | h1 { 12 | color: hotpink; 13 | } 14 | 15 | h3 { 16 | color: hotpink; 17 | } 18 | -------------------------------------------------------------------------------- /Day043/Lectures/lec06/paula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day043/Lectures/lec06/paula.png -------------------------------------------------------------------------------- /Day043/Project/css/styles.css: -------------------------------------------------------------------------------- 1 | /******************************* TAG SELECTORS *******************************/ 2 | body { 3 | background-color: chocolate; 4 | } 5 | h1 { 6 | color: white; 7 | font-size: 100px; 8 | } 9 | 10 | p { 11 | color: wheat; 12 | font-size: 25px; 13 | } 14 | table { 15 | border-spacing: 50px; 16 | } 17 | /*************************** CLASS SELECTORS *********************************/ 18 | 19 | .mm { 20 | height: 400px; 21 | } 22 | 23 | .beans { 24 | height: 200px; 25 | } 26 | 27 | /*************************** ID SELECTORS *********************************/ 28 | 29 | #header { 30 | color: aqua; 31 | } 32 | -------------------------------------------------------------------------------- /Day043/Project/images/beans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day043/Project/images/beans.png -------------------------------------------------------------------------------- /Day043/Project/images/mm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pullynnhah/100DaysOfCode/92ce4d8d881b0b9f25722f46c1fd81adfbf4fcdf/Day043/Project/images/mm.jpg -------------------------------------------------------------------------------- /Day043/Project/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | m&m's Fansite 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

I 💖 m&m's

m&m's image
15 |

m&m's, m&m's, m&m's, m&m's, m&m's, m&m's

16 |

m&m's, m&m's, m&m's, m&m's, m&m's, m&m's

17 |

m&m's, m&m's, m&m's, m&m's, m&m's, m&m's

18 | 19 | 20 | 21 | 22 |

I 🤮 beans

beans crossed image
23 | 24 | 25 | 26 | --------------------------------------------------------------------------------