├── README.md ├── contacts.json ├── project1.py ├── project2.py ├── project3.py ├── project4.py ├── project5.py └── questions.json /README.md: -------------------------------------------------------------------------------- 1 | # LearnPythonWith5Projects 2 | 3 | # 💻 Launch Your Software Development Career Today! 4 | 5 | 🎓 **No degree? No problem!** My program equips you with everything you need to break into tech and land an entry-level software development role. 6 | 7 | 🚀 **Why Join?** 8 | - 💼 **$70k+ starting salary potential** 9 | - 🕐 **Self-paced:** Complete on your own time 10 | - 🤑 **Affordable:** Low risk compared to expensive bootcamps or degrees 11 | - 🎯 **45,000+ job openings** in the market 12 | 13 | 👉 **[Start your journey today!](https://techwithtim.net/dev)** 14 | No experience needed—just your determination. Future-proof your career and unlock six-figure potential like many of our students have! 15 | -------------------------------------------------------------------------------- /contacts.json: -------------------------------------------------------------------------------- 1 | { 2 | "contacts": [ 3 | { 4 | "name": "tim", 5 | "age": "24", 6 | "email": "tim@gmail.com" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /project1.py: -------------------------------------------------------------------------------- 1 | name = input("Hey type your name: ") 2 | print("Hello " + name + " welcome to my game!") 3 | 4 | should_we_play = input("Do you want to play? ").lower() 5 | 6 | if should_we_play == "y" or should_we_play == "yes": 7 | print("We are gonna play!") 8 | 9 | direction = input("Do you want to go left or right? (left/right) ").lower() 10 | if direction == "left": 11 | print("You went left and fell of a cliff, game over, try again.") 12 | elif direction == "right": 13 | choice = input( 14 | "Okay, you now see a bridge, do you want to swim under it or cross it? (swim/cross) " 15 | ) 16 | if choice == "swim": 17 | print("You got eaten by an alligator, you die, the end!") 18 | else: 19 | print("You found the gold and won!") 20 | else: 21 | print("Sorry not a valid reply, you die!") 22 | 23 | else: 24 | print("We are NOT playing...") 25 | -------------------------------------------------------------------------------- /project2.py: -------------------------------------------------------------------------------- 1 | def get_number(number): 2 | while True: 3 | operand = input("Number " + str(number) + ": ") 4 | try: 5 | return float(operand) 6 | except: 7 | print("Invalid number, try again.") 8 | 9 | 10 | operand = get_number(1) 11 | operand2 = get_number(2) 12 | sign = input("Sign: ") 13 | 14 | 15 | result = 0 16 | if sign == "+": 17 | result = operand + operand2 18 | elif sign == "-": 19 | result = operand - operand2 20 | elif sign == "/": 21 | if operand2 != 0: 22 | result = operand / operand2 23 | else: 24 | print("Division by zero.") 25 | elif sign == "*": 26 | result = operand * operand2 27 | else: 28 | print("Invalid sign.") 29 | 30 | print(result) 31 | -------------------------------------------------------------------------------- /project3.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | 4 | def add_person(): 5 | name = input("Name: ") 6 | age = input("Age: ") 7 | email = input("Email: ") 8 | 9 | person = {"name": name, "age": age, "email": email} 10 | return person 11 | 12 | 13 | def display_people(people): 14 | for i, person in enumerate(people): 15 | print(i + 1, "-", person["name"], "|", person["age"], "|", person["email"]) 16 | 17 | 18 | def delete_contact(people): 19 | display_people(people) 20 | 21 | while True: 22 | number = input("Enter a number to delete: ") 23 | try: 24 | number = int(number) 25 | if number <= 0 or number > len(people): 26 | print("Invalid number, out of range.") 27 | else: 28 | break 29 | except: 30 | print("Invalid number") 31 | 32 | people.pop(number - 1) 33 | print("Person deleted.") 34 | 35 | 36 | def search(people): 37 | search_name = input("Search for a name: ").lower() 38 | results = [] 39 | 40 | for person in people: 41 | name = person["name"] 42 | if search_name in name.lower(): 43 | results.append(person) 44 | 45 | display_people(results) 46 | 47 | 48 | print("Hi, welcome to the Contact Managament System.") 49 | print() 50 | 51 | with open("contacts.json", "r") as f: 52 | people = json.load(f)["contacts"] 53 | 54 | while True: 55 | print() 56 | print("Contact list size:", len(people)) 57 | command = input("You can 'Add', 'Delete' or 'Search' and 'Q' for quit: ").lower() 58 | 59 | if command == "add": 60 | person = add_person() 61 | people.append(person) 62 | print("Peron added!") 63 | elif command == "delete": 64 | delete_contact(people) 65 | elif command == "search": 66 | search(people) 67 | elif command == "q": 68 | break 69 | else: 70 | print("Invalid command.") 71 | 72 | with open("contacts.json", "w") as f: 73 | json.dump({"contacts": people}, f) 74 | -------------------------------------------------------------------------------- /project4.py: -------------------------------------------------------------------------------- 1 | def print_board(board): 2 | for i, row in enumerate(board): 3 | row_str = " " 4 | for j, value in enumerate(row): 5 | row_str += value 6 | if j != len(row) - 1: 7 | row_str += " | " 8 | 9 | print(row_str) 10 | if i != len(board) - 1: 11 | print("----------") 12 | 13 | 14 | def get_move(turn, board): 15 | while True: 16 | row = int(input("Row: ")) 17 | col = int(input("Col: ")) 18 | 19 | if row < 1 or row > len(board): 20 | print("Invalid row, try again.") 21 | elif col < 1 or col > len(board[row - 1]): 22 | print("Invalid col, try again.") 23 | elif board[row - 1][col - 1] != " ": 24 | print("Already taken, try again") 25 | else: 26 | break 27 | board[row - 1][col - 1] = turn 28 | 29 | 30 | def check_win(board, turn): 31 | lines = [ 32 | [(0, 0), (0, 1), (0, 2)], 33 | [(1, 0), (1, 1), (1, 2)], 34 | [(2, 0), (2, 1), (2, 2)], 35 | [(0, 0), (1, 0), (2, 0)], 36 | [(0, 1), (1, 1), (2, 1)], 37 | [(0, 2), (1, 2), (2, 2)], 38 | [(0, 0), (1, 1), (2, 2)], 39 | [(0, 2), (1, 1), (2, 0)], 40 | ] 41 | for line in lines: 42 | win = True 43 | for pos in line: 44 | row, col = pos 45 | if board[row][col] != turn: 46 | win = False 47 | break 48 | 49 | if win: 50 | return True 51 | 52 | return False 53 | 54 | 55 | board = [ 56 | [" ", " ", " "], 57 | [" ", " ", " "], 58 | [" ", " ", " "], 59 | ] 60 | 61 | turn = "X" 62 | turn_number = 0 63 | print_board(board) 64 | 65 | while turn_number < 9: 66 | print() 67 | print("It is the", turn, "players turn. Please select your move.") 68 | 69 | get_move(turn, board) 70 | 71 | print_board(board) 72 | winner = check_win(board, turn) 73 | if winner: 74 | break 75 | 76 | if turn == "X": 77 | turn = "O" 78 | else: 79 | turn = "X" 80 | turn_number += 1 81 | 82 | if turn_number == 9: 83 | print("Tied game.") 84 | else: 85 | print("The winner was", turn) 86 | -------------------------------------------------------------------------------- /project5.py: -------------------------------------------------------------------------------- 1 | import random 2 | import json 3 | import time 4 | 5 | 6 | def load_questions(): 7 | with open("questions.json", "r") as f: 8 | questions = json.load(f)["questions"] 9 | 10 | return questions 11 | 12 | 13 | def get_random_questions(questions, num_questions): 14 | if num_questions > len(questions): 15 | num_questions = len(questions) 16 | 17 | random_questions = random.sample(questions, num_questions) 18 | return random_questions 19 | 20 | 21 | def ask_question(question): 22 | print(question["question"]) 23 | for i, option in enumerate(question["options"]): 24 | print(str(i + 1) + ".", option) 25 | 26 | number = int(input("Select the correct number: ")) 27 | if number < 1 or number > len(question["options"]): 28 | print("Invalid choice, defaulting to wrong answer.") 29 | return False 30 | 31 | correct = question["options"][number - 1] == question["answer"] 32 | return correct 33 | 34 | 35 | questions = load_questions() 36 | total_questions = int(input("Enter the number of questions: ")) 37 | random_questions = get_random_questions(questions, total_questions) 38 | correct = 0 39 | start_time = time.time() 40 | 41 | for question in random_questions: 42 | is_correct = ask_question(question) 43 | if is_correct: 44 | correct += 1 45 | 46 | print("-----------------") 47 | 48 | completed_time = time.time() - start_time 49 | print("Summary") 50 | print("Total Questions:", total_questions) 51 | print("Correct Answers:", correct) 52 | print("Score:", str(round((correct / total_questions) * 100, 2)) + "%") 53 | print("Time:", round(completed_time, 2), "seconds") 54 | -------------------------------------------------------------------------------- /questions.json: -------------------------------------------------------------------------------- 1 | { 2 | "questions": [ 3 | { 4 | "question": "What is the largest planet in our solar system?", 5 | "options": [ 6 | "Earth", 7 | "Mars", 8 | "Jupiter", 9 | "Saturn" 10 | ], 11 | "answer": "Jupiter" 12 | }, 13 | { 14 | "question": "Which element has the chemical symbol 'O'?", 15 | "options": [ 16 | "Osmium", 17 | "Oxygen", 18 | "Gold", 19 | "Oganesson" 20 | ], 21 | "answer": "Oxygen" 22 | }, 23 | { 24 | "question": "Who wrote 'To Kill a Mockingbird'?", 25 | "options": [ 26 | "Harper Lee", 27 | "Mark Twain", 28 | "Ernest Hemingway", 29 | "F. Scott Fitzgerald" 30 | ], 31 | "answer": "Harper Lee" 32 | }, 33 | { 34 | "question": "What is the boiling point of water in Celsius?", 35 | "options": [ 36 | "90", 37 | "100", 38 | "110", 39 | "120" 40 | ], 41 | "answer": "100" 42 | }, 43 | { 44 | "question": "Which country is known as the Land of the Rising Sun?", 45 | "options": [ 46 | "China", 47 | "Thailand", 48 | "Japan", 49 | "South Korea" 50 | ], 51 | "answer": "Japan" 52 | }, 53 | { 54 | "question": "What is the hardest natural substance on Earth?", 55 | "options": [ 56 | "Gold", 57 | "Iron", 58 | "Diamond", 59 | "Platinum" 60 | ], 61 | "answer": "Diamond" 62 | }, 63 | { 64 | "question": "Which planet is closest to the sun?", 65 | "options": [ 66 | "Earth", 67 | "Venus", 68 | "Mercury", 69 | "Mars" 70 | ], 71 | "answer": "Mercury" 72 | }, 73 | { 74 | "question": "Who painted the Mona Lisa?", 75 | "options": [ 76 | "Vincent van Gogh", 77 | "Pablo Picasso", 78 | "Leonardo da Vinci", 79 | "Michelangelo" 80 | ], 81 | "answer": "Leonardo da Vinci" 82 | }, 83 | { 84 | "question": "What is the capital of Canada?", 85 | "options": [ 86 | "Toronto", 87 | "Ottawa", 88 | "Montreal", 89 | "Vancouver" 90 | ], 91 | "answer": "Ottawa" 92 | }, 93 | { 94 | "question": "How many continents are there on Earth?", 95 | "options": [ 96 | "5", 97 | "6", 98 | "7", 99 | "8" 100 | ], 101 | "answer": "7" 102 | }, 103 | { 104 | "question": "Which gas do plants absorb from the atmosphere?", 105 | "options": [ 106 | "Oxygen", 107 | "Carbon Dioxide", 108 | "Nitrogen", 109 | "Hydrogen" 110 | ], 111 | "answer": "Carbon Dioxide" 112 | }, 113 | { 114 | "question": "What is the smallest prime number?", 115 | "options": [ 116 | "0", 117 | "1", 118 | "2", 119 | "3" 120 | ], 121 | "answer": "2" 122 | }, 123 | { 124 | "question": "In which year did the Titanic sink?", 125 | "options": [ 126 | "1910", 127 | "1912", 128 | "1914", 129 | "1916" 130 | ], 131 | "answer": "1912" 132 | }, 133 | { 134 | "question": "What is the square root of 64?", 135 | "options": [ 136 | "6", 137 | "7", 138 | "8", 139 | "9" 140 | ], 141 | "answer": "8" 142 | }, 143 | { 144 | "question": "Who discovered penicillin?", 145 | "options": [ 146 | "Marie Curie", 147 | "Alexander Fleming", 148 | "Isaac Newton", 149 | "Albert Einstein" 150 | ], 151 | "answer": "Alexander Fleming" 152 | } 153 | ] 154 | } --------------------------------------------------------------------------------