├── .github └── FUNDING.yml ├── README.md ├── binary_search.py ├── login.py ├── madlibs.py ├── random_madlibs.py ├── rock_paper_scissors.py ├── sample_madlibs ├── code.py ├── hp.py ├── hungergames.py └── zombie.py ├── selector.py └── web_app ├── __pycache__ └── web.cpython-37.pyc ├── static └── home.css ├── templates └── home.html └── web.py /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # [kying18] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Beginner Projects 2 | 3 | A couple of beginner projects here, listed from easiest to hardest :) 4 | 5 | - `selector.py`: simply a random selector to tell me who to facetime! (deals with imports) 6 | - `login.py`: a fake login that lets you look like you're hacking into some super secret mainframe lol (practice with if statements, imports, print statements) 7 | - `madlibs.py`: madlibs! (practice with inputs, strings) 8 | - `rock_paper_scissors.py`: rock paper scissors (practice with functions and if statements) 9 | - NOTE: `random_madlibs.py` and `sample_madlibs` are madlibs that I created if you just want to play around with them 10 | - `web_app`: build your own web app using flask! (this would be more intermediate, but give it a try if you're feeling ambitious!!) 11 | 12 | Relevant YouTube videos: 13 | - Selector, rock paper scissors, and web app: https://www.youtube.com/watch?v=CDw3oKV5arA 14 | - Login, madlibs: https://www.youtube.com/watch?v=O69N6Gk3eaw 15 | 16 | Associated links: 17 | YouTube Kylie Ying: https://www.youtube.com/ycubed 18 | Twitch KylieYing: https://www.twitch.tv/kylieying 19 | Twitter @kylieyying: https://twitter.com/kylieyying 20 | Instagram @kylieyying: https://www.instagram.com/kylieyying/ 21 | Website: https://www.kylieying.com 22 | Github: https://www.github.com/kying18 23 | Programmer Beast Mode Spotify playlist: https://open.spotify.com/playlist/4Akns5EUb3gzmlXIdsJkPs?si=qGc4ubKRRYmPHAJAIrCxVQ 24 | -------------------------------------------------------------------------------- /binary_search.py: -------------------------------------------------------------------------------- 1 | """ 2 | Beginner Python Project - Binary Search Implementation by Kylie Ying 3 | 4 | YouTube Kylie Ying: https://www.youtube.com/ycubed 5 | Twitch KylieYing: https://www.twitch.tv/kylieying 6 | Twitter @kylieyying: https://twitter.com/kylieyying 7 | Instagram @kylieyying: https://www.instagram.com/kylieyying/ 8 | Website: https://www.kylieying.com 9 | Github: https://www.github.com/kying18 10 | Programmer Beast Mode Spotify playlist: https://open.spotify.com/playlist/4Akns5EUb3gzmlXIdsJkPs?si=qGc4ubKRRYmPHAJAIrCxVQ 11 | """ 12 | 13 | import random 14 | import time 15 | 16 | # Implementation of binary search algorithm!! 17 | 18 | # We will prove that binary search is faster than naive search! 19 | 20 | 21 | # Essence of binary search: 22 | # If you have a sorted list and you want to search this array for something, 23 | # You could go through each item in the list and ask, is this equal to what we're looking for? 24 | # But we can make this *faster* by leveraging the fact that our array is sorted! 25 | # Binary search ~ O(log(n)), naive search ~ O(n) 26 | 27 | # In these two examples, l is a list in ascending order, and target is something that we're looking for 28 | # Return -1 if not found 29 | 30 | 31 | # naive search: scan entire list and ask if its equal to the target 32 | # if yes, return the index 33 | # if no, then return -1 34 | def naive_search(l, target): 35 | # example l = [1, 3, 10, 12] 36 | for i in range(len(l)): 37 | if l[i] == target: 38 | return i 39 | return -1 40 | 41 | 42 | # binary search uses divide and conquer! 43 | # we will leverage the fact that our list is SORTED 44 | def binary_search(l, target, low=None, high=None): 45 | if low is None: 46 | low = 0 47 | if high is None: 48 | high = len(l) - 1 49 | 50 | if high < low: 51 | return -1 52 | 53 | # example l = [1, 3, 5, 10, 12] # should return 3 54 | midpoint = (low + high) // 2 # 2 55 | 56 | # we'll check if l[midpoint] == target, and if not, we can find out if 57 | # target will be to the left or right of midpoint 58 | # we know everything to the left of midpoint is smaller than the midpoint 59 | # and everything to the right is larger 60 | if l[midpoint] == target: 61 | return midpoint 62 | elif target < l[midpoint]: 63 | return binary_search(l, target, low, midpoint-1) 64 | else: 65 | # target > l[midpoint] 66 | return binary_search(l, target, midpoint+1, high) 67 | 68 | if __name__=='__main__': 69 | # l = [1, 3, 5, 10, 12] 70 | # target = 7 71 | # print(naive_search(l, target)) 72 | # print(binary_search(l, target)) 73 | 74 | length = 10000 75 | # build a sorted list of length 10000 76 | sorted_list = set() 77 | while len(sorted_list) < length: 78 | sorted_list.add(random.randint(-3*length, 3*length)) 79 | sorted_list = sorted(list(sorted_list)) 80 | 81 | start = time.time() 82 | for target in sorted_list: 83 | naive_search(sorted_list, target) 84 | end = time.time() 85 | print("Naive search time: ", (end - start), "seconds") 86 | 87 | start = time.time() 88 | for target in sorted_list: 89 | binary_search(sorted_list, target) 90 | end = time.time() 91 | print("Binary search time: ", (end - start), "seconds") 92 | -------------------------------------------------------------------------------- /login.py: -------------------------------------------------------------------------------- 1 | """ 2 | Beginner Python Project using input, print, and conditionals by Kylie Ying 3 | 4 | YouTube Kylie Ying: https://www.youtube.com/ycubed 5 | Twitch KylieYing: https://www.twitch.tv/kylieying 6 | Twitter @kylieyying: https://twitter.com/kylieyying 7 | Instagram @kylieyying: https://www.instagram.com/kylieyying/ 8 | Website: https://www.kylieying.com 9 | Github: https://www.github.com/kying18 10 | Programmer Beast Mode Spotify playlist: https://open.spotify.com/playlist/4Akns5EUb3gzmlXIdsJkPs?si=qGc4ubKRRYmPHAJAIrCxVQ 11 | """ 12 | 13 | import time 14 | 15 | username = 'kylie' 16 | password = 'secretpassword' 17 | 18 | username_input = input('Username: ') 19 | password_input = input('Password: ') 20 | 21 | if username_input == username and password_input == password: 22 | print('Access granted') 23 | print('Please wait') 24 | time.sleep(5) 25 | print('Ok... Loading...') 26 | time.sleep(1) 27 | print('...') 28 | time.sleep(1) 29 | print('...') 30 | print('Alright you have security clearance. Pulling up the secret mainframe.') 31 | elif username_input == username and password_input != password: 32 | print('Password incorrect') 33 | elif username_input != username and password_input == password: 34 | print('Username incorrect') 35 | else: 36 | print('You might wanna check both fields...') -------------------------------------------------------------------------------- /madlibs.py: -------------------------------------------------------------------------------- 1 | """ 2 | Very Beginner Python Project by Kylie Ying 3 | Madlibs using string concatenation 4 | 5 | YouTube Kylie Ying: https://www.youtube.com/ycubed 6 | Twitch KylieYing: https://www.twitch.tv/kylieying 7 | Twitter @kylieyying: https://twitter.com/kylieyying 8 | Instagram @kylieyying: https://www.instagram.com/kylieyying/ 9 | Website: https://www.kylieying.com 10 | Github: https://www.github.com/kying18 11 | Programmer Beast Mode Spotify playlist: https://open.spotify.com/playlist/4Akns5EUb3gzmlXIdsJkPs?si=qGc4ubKRRYmPHAJAIrCxVQ 12 | """ 13 | # # string concatenation (aka how to put strings together) 14 | # # suppose we want to create a string that says "subscribe to _____ " 15 | # youtuber = "Kylie Ying" # some string variable 16 | 17 | # # a few ways to do this 18 | # print("subscribe to " + youtuber) 19 | # print("subscribe to {}".format(youtuber)) 20 | # print(f"subscribe to {youtuber}") 21 | 22 | adj = input("Adjective: ") 23 | verb1 = input("Verb: ") 24 | verb2 = input("Verb: ") 25 | famous_person = input("Famous person: ") 26 | 27 | madlib = f"Computer programming is so {adj}! It makes me so excited all the time because \ 28 | I love to {verb1}. Stay hydrated and {verb2} like you are {famous_person}!" 29 | 30 | print(madlib) -------------------------------------------------------------------------------- /random_madlibs.py: -------------------------------------------------------------------------------- 1 | from sample_madlibs import hp, code, zombie, hungergames 2 | import random 3 | 4 | if __name__ == "__main__": 5 | m = random.choice([hp, code, zombie, hungergames]) 6 | m.madlib() -------------------------------------------------------------------------------- /rock_paper_scissors.py: -------------------------------------------------------------------------------- 1 | """ 2 | Implementation of rock, paper, scissors by Kylie Ying 3 | 4 | YouTube Kylie Ying: https://www.youtube.com/ycubed 5 | Twitch KylieYing: https://www.twitch.tv/kylieying 6 | Twitter @kylieyying: https://twitter.com/kylieyying 7 | Instagram @kylieyying: https://www.instagram.com/kylieyying/ 8 | Website: https://www.kylieying.com 9 | Github: https://www.github.com/kying18 10 | Programmer Beast Mode Spotify playlist: https://open.spotify.com/playlist/4Akns5EUb3gzmlXIdsJkPs?si=qGc4ubKRRYmPHAJAIrCxVQ 11 | """ 12 | 13 | import random 14 | 15 | def play(): 16 | user = input("What's your choice? 'r' for rock, 'p' for paper, 's' for scissors\n") 17 | computer = random.choice(['r', 'p', 's']) 18 | 19 | if user == computer: 20 | return 'It\'s a tie' 21 | 22 | # r > s, s > p, p > r 23 | if is_win(user, computer): 24 | return 'You won!' 25 | 26 | return 'You lost!' 27 | 28 | def is_win(player, opponent): 29 | # return true if player wins 30 | # r > s, s > p, p > r 31 | if (player == 'r' and opponent == 's') or (player == 's' and opponent == 'p') \ 32 | or (player == 'p' and opponent == 'r'): 33 | return True 34 | 35 | print(play()) 36 | -------------------------------------------------------------------------------- /sample_madlibs/code.py: -------------------------------------------------------------------------------- 1 | def madlib(): 2 | body_part = input("Body Part: ") 3 | verb = input("Verb: ") 4 | adj1 = input("Adjective: ") 5 | adj2 = input("Adjective: ") 6 | adj3 = input("Adjective: ") 7 | adj4 = input("Adjective: ") 8 | adj5 = input("Adjective: ") 9 | noun1 = input("Noun: ") 10 | noun2 = input("Noun: ") 11 | noun_plural_1 = input("Noun (plural): ") 12 | noun_plural_2 = input("Noun (plural): ") 13 | 14 | madlib = f"I love computer programming because it's {adj1}! The journey to becoming a \ 15 | good programmer starts with hope in your mind and a dream in your {body_part}. Through blood, \ 16 | sweat, and {noun_plural_1}, hopefully it never ends. Yes, once you learn to {verb}, it becomes \ 17 | a part of your life identity and you can become a super {adj2} hacker. Knowledge of programming \ 18 | lets you take control of your {noun1}. You can create your own personal {noun_plural_2}, anything \ 19 | from developing {adj3} software to analyzing data and making predictions about the {noun2}. You can \ 20 | maybe even recreate Jarvis and make him extra {adj4}. I hope you'll start your {adj5} journey by \ 21 | coding with Kylie :)" 22 | 23 | print(madlib) -------------------------------------------------------------------------------- /sample_madlibs/hp.py: -------------------------------------------------------------------------------- 1 | def madlib(): 2 | adj1 = input("Adjective: ") 3 | adj2 = input("Adjective: ") 4 | adj3 = input("Adjective: ") 5 | adj4 = input("Adjective: ") 6 | noun1 = input("Noun: ") 7 | noun2 = input("Noun: ") 8 | noun3 = input("Noun: ") 9 | noun4 = input("Noun: ") 10 | noun5 = input("Noun: ") 11 | noun6 = input("Noun: ") 12 | noun_plural = input("Noun plural: ") 13 | body_part = input("Body part: ") 14 | body_part2 = input("Body part: ") 15 | verb = input("Verb: ") 16 | verb_past = input("Verb (past tense): ") 17 | verb_past2 = input("Verb (past tense): ") 18 | spell1 = input("Spell: ") 19 | spell2 = input("Spell: ") 20 | 21 | 22 | madlib = f"A {adj1} glow burst suddenly across the enchanted sky above them as an edge of \ 23 | dazzling sun appeared over the sill of the nearest {noun1}. The light hit both of their {body_part} \ 24 | at the same time, so that Voldemort’s was suddenly a flaming {noun2}. Harry heard the high voice \ 25 | shriek as he too {verb_past} his best hope to the heavens, pointing Draco’s {noun3}:\n\ 26 | \"{spell1}!\"\n\ 27 | \"{spell2}!\"\n\ 28 | The bang was like a cannon blast, and the {adj2} flames that erupted between them, \ 29 | at the dead center of the circle they had been treading, marked the point where the \ 30 | {noun_plural} collided. Harry saw Voldemort’s {adj3} jet meet his own spell, saw the Elder Wand \ 31 | fly high, dark against the sunrise, spinning across the enchanted ceiling like the \ 32 | head of Nagini, spinning through the air toward the master it would not {verb}, who had \ 33 | come to take full possession of it at last. And Harry, with the unerring skill of a Seeker, \ 34 | caught the {noun4} in his free hand as Voldemort fell backward, arms splayed, the slit pupils \ 35 | of the {adj4} {body_part2} rolling upward. Tom Riddle hit the floor with a mundane finality, his body \ 36 | feeble and shrunken, the white hands empty, the snakelike face vacant and unknowing. Voldemort \ 37 | was dead, {verb_past2} by his own rebounding {noun5}, and Harry stood with two wands in his hands, \ 38 | staring down at his enemy’s {noun6}." 39 | 40 | print(madlib) -------------------------------------------------------------------------------- /sample_madlibs/hungergames.py: -------------------------------------------------------------------------------- 1 | def madlib(): 2 | number = input("Number: ") 3 | adj = input("Adjective: ") 4 | verb = input("Verb: ") 5 | verb2 = input("Verb: ") 6 | noun = input("Noun: ") 7 | noun2 = input("Noun: ") 8 | noun3 = input("Noun: ") 9 | noun4 = input("Noun: ") 10 | noun5 = input("Noun: ") 11 | noun_plural = input("Noun (plural): ") 12 | noun_plural_2 = input("Noun (plural): ") 13 | noun_plural_3 = input("Noun (plural): ") 14 | sound_important = input("Name of something that sounds important: ") 15 | 16 | 17 | madlib=f"{number} seconds. That’s how long we’re required to {verb} on our metal circles before \ 18 | the sound of a {noun} releases us. Step off before the {number} seconds is up, and {noun_plural} blow your \ 19 | legs off. {number} seconds to take in the ring of tributes all equidistant from the {sound_important}, a giant \ 20 | {adj} {noun2} shaped like a {noun3} with a curved tail, the mouth of which is at least twenty feet \ 21 | high, spilling over with the things that will give us life here in the arena. Food, containers of water, \ 22 | {noun_plural_2}, medicine, garments, {noun_plural_3}. Strewn around the {sound_important} are other supplies, their value \ 23 | decreasing the farther they are from the {noun2}. For instance, only a few steps from my feet lies a three-foot \ 24 | square of {noun4}. Certainly it could be of some use in a downpour. But there in the mouth, I can see a {noun5} \ 25 | that would protect from almost any sort of weather. If I had the guts to go in and {verb2} for it against \ 26 | the other twenty-three tributes. Which I have been instructed not to do." 27 | 28 | print(madlib) 29 | 30 | if __name__ == '__main__': 31 | madlib() -------------------------------------------------------------------------------- /sample_madlibs/zombie.py: -------------------------------------------------------------------------------- 1 | def madlib(): 2 | time_of_day = input("Time of Day: ") 3 | body_part_plural = input("Body Part (plural): ") 4 | color = input("Color: ") 5 | verb_past_tense = input("Verb (past tense): ") 6 | food = input("Food: ") 7 | noun1 = input("Noun: ") 8 | noun_plural_1 = input("Noun (plural): ") 9 | adj1 = input("Adjective: ") 10 | adj2 = input("Adjective: ") 11 | adj3 = input("Adjective: ") 12 | 13 | 14 | madlib = f"It was a {adj1} summer {time_of_day} when we realized that the vaccine to stop \ 15 | spread of the disease did not work. Instead, it produced ZOMBIES!!! They were thirsty for {body_part_plural} \ 16 | and the streets were lined with these monsters holding {noun_plural_1} in their hands. \ 17 | Their eyes were {color} with hunger as they {verb_past_tense} around the city looking for {food}. \ 18 | They were {adj2} and {adj3}, unknowing how to act in this human world... except eat {body_part_plural}!!!! \ 19 | That was their sole mission and they were dedicated towards achieving it for the sake of {noun1}." 20 | 21 | print(madlib) -------------------------------------------------------------------------------- /selector.py: -------------------------------------------------------------------------------- 1 | """ 2 | Easy Python project :P 3 | Random friend selector to decide who to FaceTime!!! 4 | 5 | YouTube Kylie Ying: https://www.youtube.com/ycubed 6 | Twitch KylieYing: https://www.twitch.tv/kylieying 7 | Twitter @kylieyying: https://twitter.com/kylieyying 8 | Instagram @kylieyying: https://www.instagram.com/kylieyying/ 9 | Website: https://www.kylieying.com 10 | Github: https://www.github.com/kying18 11 | Programmer Beast Mode Spotify playlist: https://open.spotify.com/playlist/4Akns5EUb3gzmlXIdsJkPs?si=qGc4ubKRRYmPHAJAIrCxVQ 12 | """ 13 | 14 | import random 15 | 16 | friends = [ 17 | 'Olek', 18 | 'Carmela', 19 | 'Laura', 20 | 'Megan', 21 | 'Keith', 22 | 'Anna', 23 | 'Skyler', 24 | 'Amy', 25 | 'Nadya' 26 | ] 27 | 28 | # random.randint(1, 5) --> random number between 1 and 5 29 | # random.choice(array) --> random item in this array 30 | 31 | selected = random.choice(friends) # randomly choose a friend 32 | 33 | print('Who should I facetime today?') 34 | print(selected) 35 | -------------------------------------------------------------------------------- /web_app/__pycache__/web.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kying18/beginner-projects/653f5a635f56f3821ad1d098d8b8d5f38b577b0d/web_app/__pycache__/web.cpython-37.pyc -------------------------------------------------------------------------------- /web_app/static/home.css: -------------------------------------------------------------------------------- 1 | .container { 2 | text-align: center; 3 | border: 2px solid red; 4 | } 5 | 6 | .message-part-1 { 7 | color: rgb(100, 0, 0); 8 | } 9 | 10 | .message-part-2 { 11 | color: rgb(0, 0, 100); 12 | } 13 | -------------------------------------------------------------------------------- /web_app/templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |