├── .gitignore ├── Exercise 0: Calculating Taxi Rides.md ├── Exercise 10: Plaindrom.md ├── Exercise 11: Line of hashes.md ├── Exercise 12: Rectangle of hashes.md ├── Exercise 13: Underline.md ├── Exercise 14: Framed word.md ├── Exercise 15: Does it contain vowels.md ├── Exercise 16: Mutability in Lists.md ├── Exercise 17: List Initialization and Append.md ├── Exercise 18: Interactive List Operations.md ├── Exercise 19: Unique Word Counter.md ├── Exercise 1: Ticket Purchase System.md ├── Exercise 20: Sorted List Builder.md ├── Exercise 21: List Statistics.md ├── Exercise 22: Start-string.md ├── Exercise 23: From negative to positive.md ├── Exercise 24: arguments.md ├── Exercise 2: Temperature Check.md ├── Exercise 3: Exercise- Discount Calculation.md ├── Exercise 4: Determine the Oldest Age.md ├── Exercise 5: Determine the Faster Runner.md ├── Exercise 6: Separating Dinars and Centimes ├── Exercise 7: Leap Year Exercise.md ├── Exercise 8: FizzBuzz Exercise.md ├── Exercise 9: Name Length Kingdom.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | solutions/* 2 | solutions 3 | exemples 4 | exemples/* -------------------------------------------------------------------------------- /Exercise 0: Calculating Taxi Rides.md: -------------------------------------------------------------------------------- 1 | ### Exercise: Calculating Taxi Rides 2 | 3 | Write a program that calculates how many taxi rides are needed to transport a group of people. 4 | The program should: 5 | 1. Ask the user how many people need a ride. 6 | 2. Ask the user how many people can fit in one taxi. 7 | 3. Calculate and print the number of taxis required to transport everyone. If the number doesn't divide evenly, the last taxi may carry fewer people. 8 | 9 | #### Sample Output: 10 | ``` 11 | How many people need a ride? 10 12 | How many people fit in one taxi? 4 13 | Number of taxis needed: 3 14 | ``` 15 | 16 | #### Hint: 17 | - Use the integer division operator `//` to calculate full taxis. 18 | - Use the modulus operator `%` to check if there's a remainder, indicating an extra taxi is needed. 19 | 20 | add some text to see the difference 21 | 22 | add some text being in the dev exercices branch 23 | -------------------------------------------------------------------------------- /Exercise 10: Plaindrom.md: -------------------------------------------------------------------------------- 1 | ### **Exercise: Palindrome Checker** 2 | 3 | **Objective**: Write a program that checks whether a word is a palindrome, using negative indexing and loops. 4 | 5 | ### **Task**: 6 | 1. **Input**: 7 | - Ask the user to type in a word. 8 | 2. **Loop through the first half of the word**: 9 | - Compare each character in the word from the start and the end using negative indexing. 10 | - If at any point the characters do not match, the word is not a palindrome. 11 | 3. **Output**: 12 | - After the loop, print `Yes, it's a palindrome.` if all characters match. 13 | - If any characters do not match, print `No, it's not a palindrome.` 14 | 15 | ### **Steps**: 16 | 1. **Request Input**: 17 | - Prompt the user to type a word. 18 | 2. **Check for Palindrome**: 19 | - Use a loop to compare characters from the beginning and end of the string. 20 | - If any characters don't match, set a variable `is_palindrome` to `False` and stop the loop. 21 | 3. **Output the Result**: 22 | - After finishing the loop, print the result based on whether `is_palindrome` is `True` or `False`. 23 | 24 | ### **Example**: 25 | 26 | 1. **Input**: 27 | ``` 28 | racecar 29 | ``` 30 | **Output**: 31 | ``` 32 | Yes, it's a palindrome. 33 | ``` 34 | 35 | 2. **Input**: 36 | ``` 37 | hello 38 | ``` 39 | **Output**: 40 | ``` 41 | No, it's not a palindrome. 42 | ``` 43 | 44 | --- 45 | 46 | **Bonus**: Try testing the program with multiple words and phrases. -------------------------------------------------------------------------------- /Exercise 11: Line of hashes.md: -------------------------------------------------------------------------------- 1 | Please write a program which prints out a line of hash characters, the width of which is chosen by the user. 2 | Sample output 3 | 4 | Width: 3 5 | 6 | ### 7 | 8 | Sample output 9 | 10 | Width: 8 11 | 12 | ######## 13 | -------------------------------------------------------------------------------- /Exercise 12: Rectangle of hashes.md: -------------------------------------------------------------------------------- 1 | Please modify the previous program (exercise 11) so that it also asks for the height, and prints out a rectangle of hash characters accordingly. 2 | Sample output 3 | 4 | Width: 10 5 | Height: 3 6 | ########## 7 | ########## 8 | ########## -------------------------------------------------------------------------------- /Exercise 13: Underline.md: -------------------------------------------------------------------------------- 1 | Please write a program which asks the user for strings using a loop. The program prints out each string underlined as shown in the examples below. The execution ends when the user inputs an empty string - that is, just presses Enter at the prompt. 2 | Sample output 3 | 4 | Please type in a string: Hi there! 5 | 6 | Hi there! 7 | --------- 8 | 9 | Please type in a string: This is a test 10 | 11 | This is a test 12 | -------------- 13 | 14 | Please type in a string: a 15 | 16 | a 17 | - 18 | 19 | Please type in a string: -------------------------------------------------------------------------------- /Exercise 14: Framed word.md: -------------------------------------------------------------------------------- 1 | Please write a program which asks the user for a string and then prints out a frame of * characters with the word in the centre. The width of the frame should be 30 characters. You may assume the input string will always fit inside the frame. 2 | 3 | If the length of the input string is an odd number, you may print out the word in either of the two possible centre locations. 4 | Sample output 5 | 6 | Word: testing 7 | 8 | ****************************** 9 | * testing * 10 | ****************************** 11 | 12 | Sample output 13 | 14 | Word: python 15 | 16 | ****************************** 17 | * python * 18 | ****************************** 19 | -------------------------------------------------------------------------------- /Exercise 15: Does it contain vowels.md: -------------------------------------------------------------------------------- 1 | ### Exercise Statement: Checking for Vowels in a String 2 | 3 | **Objective**: Create a program that asks the user to input a string and checks whether certain vowels (`a`, `e`, `o`) are present in the string. 4 | 5 | **Instructions**: 6 | 7 | 1. Ask the user to input a string in lowercase. 8 | 2. Check if the vowels `a`, `e`, and `o` are present in the string. 9 | 3. For each vowel, print a message indicating whether it is present or not in the string. 10 | 4. You may assume that the user’s input will be entirely in lowercase. 11 | 12 | **Sample Output**: 13 | 14 | - **Example 1**: 15 | 16 | ``` 17 | Please type in a string: hello there 18 | a not found 19 | e found 20 | o found 21 | ``` 22 | 23 | - **Example 2**: 24 | 25 | ``` 26 | Please type in a string: hiya 27 | a found 28 | e not found 29 | o not found 30 | ``` 31 | 32 | ### Evaluation Criteria: 33 | - The program must correctly check for the presence of the specified vowels. 34 | - The program should display the result for each vowel (found or not found) in the required format. -------------------------------------------------------------------------------- /Exercise 16: Mutability in Lists.md: -------------------------------------------------------------------------------- 1 | Exercise: Mutability in Lists 2 | Objective 3 | Understand how mutability works in Python lists by updating elements dynamically. 4 | Instructions: 5 | 6 | Initialize a list: numbers = [1, 2, 3, 4, 5]. 7 | Write a program that: 8 | Asks the user for an index and a new value. 9 | Replaces the value at the given index. 10 | Prints the updated list. 11 | Repeat steps 2.1-2.3 until the user inputs -1 for the index. 12 | 13 | Example Output 14 | 15 | Enter index (-1 to quit): 2 16 | Enter new value: 10 17 | [1, 2, 10, 4, 5] 18 | Enter index (-1 to quit): 4 19 | Enter new value: 20 20 | [1, 2, 10, 4, 20] 21 | Enter index (-1 to quit): -1 22 | 23 | Grading Criteria 24 | 25 | Correct initialization of the list. 26 | User input handling for index and value. 27 | Successful updating of the list. 28 | Looping until -1 input. 29 | Code readability and organization. 30 | 31 | Bonus 32 | 33 | Handle invalid index inputs (e.g., out-of-range, non-integer). 34 | Implement input validation for the new value. -------------------------------------------------------------------------------- /Exercise 17: List Initialization and Append.md: -------------------------------------------------------------------------------- 1 | Exercise: List Initialization and Append 2 | Instructions 3 | 4 | Create two empty lists: numbers and shoe_sizes. 5 | Use the append method to add the following items to each list: 6 | numbers: 1, 2, 3, 4, 5 7 | shoe_sizes: 8, 9, 10, 11, 12 8 | Print both lists. 9 | 10 | Requirements 11 | 12 | Initialize lists correctly. 13 | Use append method correctly. 14 | Print lists with descriptive labels. 15 | 16 | Expected Output 17 | 18 | Numbers List: [1, 2, 3, 4, 5] 19 | Shoe Sizes List: [8, 9, 10, 11, 12] 20 | 21 | Grading Criteria 22 | 23 | List initialization. 24 | Correct use of append. 25 | List printing. 26 | Code readability. 27 | 28 | Bonus 29 | 30 | Add duplicate values to numbers and handle duplicates. 31 | Use a loop to append values to shoe_sizes. 32 | Create a third list combining numbers and shoe_sizes. -------------------------------------------------------------------------------- /Exercise 18: Interactive List Operations.md: -------------------------------------------------------------------------------- 1 | Exercise: Interactive List Operations 2 | Objective 3 | Implement an interactive program allowing users to modify a list using append, insert, pop, and remove operations. 4 | Instructions 5 | 6 | Initialize a list: numbers = [1, 2, 3, 4, 5]. 7 | Create a menu-driven program with options: 8 | Append an element 9 | Insert an element at a specific position 10 | Pop an element 11 | Remove an element 12 | Quit 13 | After each operation, display the updated list. 14 | 15 | Requirements 16 | 17 | Handle invalid user inputs (e.g., non-integer, out-of-range index). 18 | Implement error handling for pop and remove operations. 19 | Use descriptive prompts and messages. 20 | 21 | Example Output 22 | 23 | Initial List: [1, 2, 3, 4, 5] 24 | 25 | Menu: 26 | 1. Append 27 | 2. Insert 28 | 3. Pop 29 | 4. Remove 30 | 5. Quit 31 | 32 | Choose an option: 1 33 | Enter value: 6 34 | Updated List: [1, 2, 3, 4, 5, 6] 35 | 36 | Choose an option: 2 37 | Enter value: 10 38 | Enter index: 2 39 | Updated List: [1, 2, 10, 3, 4, 5, 6] 40 | 41 | ... 42 | 43 | Grading Criteria 44 | 45 | Correct initialization and updating of the list. 46 | Menu-driven interface. 47 | Error handling. 48 | Code readability and organization. 49 | 50 | Bonus 51 | 52 | Add sorting and reversing options. 53 | Implement searching for an element. 54 | Allow users to save the list to a file. 55 | Load a list from a file. -------------------------------------------------------------------------------- /Exercise 19: Unique Word Counter.md: -------------------------------------------------------------------------------- 1 | Exercise: Unique Word Counter 2 | Objective 3 | Create a program that: 4 | 5 | Asks users for words. 6 | Tracks unique words. 7 | Exits and displays the count of unique words when a duplicate word is entered. 8 | 9 | Instructions 10 | 11 | Initialize an empty set unique_words. 12 | Continuously prompt the user for words. 13 | Add each word to unique_words. 14 | Check for duplicates. 15 | If a duplicate is found: 16 | Print the count of unique words. 17 | Exit the program. 18 | 19 | Requirements 20 | 21 | Handle case sensitivity (consider "word" and "Word" as different). 22 | Ignore leading/trailing whitespace. 23 | Use descriptive prompts. 24 | 25 | Example Output 26 | 27 | Enter a word: Hello 28 | Enter a word: World 29 | Enter a word: Hello 30 | You typed in 2 unique words. 31 | 32 | Grading Criteria 33 | 34 | Correct use of sets for uniqueness. 35 | Duplicate detection. 36 | User input handling. 37 | Code readability. 38 | 39 | Bonus 40 | 41 | Make the program case-insensitive. 42 | Count total words (not just unique). 43 | Display unique words alphabetically. 44 | Allow users to save unique words to a file. -------------------------------------------------------------------------------- /Exercise 1: Ticket Purchase System.md: -------------------------------------------------------------------------------- 1 | ### Exercise: Ticket Purchase System 2 | 3 | Write a program that asks the user for their name. 4 | - If the name is anything but **"VIP"**, the program asks how many tickets the user wants to buy and calculates the total cost. Each ticket costs **15.50**. 5 | - If the name is **"VIP"**, the user gets a message saying, **"Enjoy the show for free!"**, and no further input is required. 6 | 7 | #### Sample Output 1: 8 | ``` 9 | Please enter your name: Alice 10 | How many tickets would you like to buy? 3 11 | The total cost is 46.5 12 | Enjoy your tickets! 13 | ``` 14 | 15 | #### Sample Output 2: 16 | ``` 17 | Please enter your name: VIP 18 | Enjoy the show for free! 19 | ``` 20 | 21 | This exercise practices these concepts: 22 | 1. Conditional execution (checking for a specific input value). 23 | 2. Basic arithmetic for calculating the total cost. 24 | 3. Input and output handling in Python. 25 | 26 | Would you like a solution for this as well? -------------------------------------------------------------------------------- /Exercise 20: Sorted List Builder.md: -------------------------------------------------------------------------------- 1 | Exercise: Sorted List Builder 2 | Objective 3 | Create a program that: 4 | 5 | Continuously asks users for numbers. 6 | Adds inputs to a list. 7 | Prints the list in two formats: 8 | 9 | Instructions 10 | 11 | Initialize an empty list user_list. 12 | Continuously prompt the user for numbers. 13 | Add each number to user_list. 14 | After each addition, print: 15 | Current List: Numbers in the order added. 16 | Sorted List: Numbers in ascending order. 17 | Stop when the user enters 0. 18 | 19 | Requirements 20 | 21 | Handle non-integer inputs. 22 | Use descriptive prompts. 23 | Maintain correct ordering. 24 | 25 | Example Output 26 | 27 | Enter a number: 5 28 | Current List: [5] 29 | Sorted List: [5] 30 | 31 | Enter a number: 2 32 | Current List: [5, 2] 33 | Sorted List: [2, 5] 34 | 35 | Enter a number: 8 36 | Current List: [5, 2, 8] 37 | Sorted List: [2, 5, 8] 38 | 39 | Enter a number: 0 40 | 41 | Grading Criteria 42 | 43 | List initialization and updating. 44 | Sorted list generation. 45 | User input handling. 46 | Code readability. 47 | 48 | Bonus 49 | 50 | Add descending order option. 51 | Calculate and display list statistics (mean, median). 52 | Allow users to save the list to a file. 53 | Load and append to an existing list. -------------------------------------------------------------------------------- /Exercise 21: List Statistics.md: -------------------------------------------------------------------------------- 1 | Exercise: List Statistics 2 | Objective 3 | Implement three functions to calculate list statistics: 4 | Functions 5 | 6 | length(lst): Returns the number of elements. 7 | mean(lst): Calculates the arithmetic mean. 8 | range_of_list(lst): Returns the difference between max and min values. 9 | 10 | Instructions 11 | 12 | Write each function with clear documentation. 13 | Handle edge cases (e.g., empty list). 14 | Test functions with sample lists. 15 | 16 | Requirements 17 | 18 | Correct calculation logic. 19 | Error handling for non-numeric values. 20 | Readable code. 21 | 22 | Example Usage 23 | Python 24 | 25 | numbers = [1, 2, 3, 4, 5] 26 | 27 | print(length(numbers)) # Output: 5 28 | print(mean(numbers)) # Output: 3.0 29 | print(range_of_list(numbers)) # Output: 4 30 | 31 | Grading Criteria 32 | 33 | Functional correctness. 34 | Error handling. 35 | Code organization and readability. 36 | 37 | Bonus 38 | 39 | Calculate median. 40 | Implement standard deviation. 41 | Create a dictionary with list statistics. 42 | Handle non-list inputs. 43 | 44 | Test Cases 45 | 46 | Empty list. 47 | List with single element. 48 | List with negative numbers. 49 | List with floating-point numbers. -------------------------------------------------------------------------------- /Exercise 22: Start-string.md: -------------------------------------------------------------------------------- 1 | Please write a program which asks the user to type in a string. 2 | The program then prints each input character on a separate line. 3 | After each character there should be a star (*) printed on its own line. 4 | 5 | This is how it should work: 6 | Sample output 7 | 8 | Please type in a string: Python 9 | P 10 | * 11 | y 12 | * 13 | t 14 | * 15 | h 16 | * 17 | o 18 | * 19 | n 20 | * -------------------------------------------------------------------------------- /Exercise 23: From negative to positive.md: -------------------------------------------------------------------------------- 1 | Write a Python program that: 2 | Asks the user for a positive integer N. 3 | Prints numbers from -N to N (inclusive), excluding 0. 4 | Each number on a separate line. 5 | 6 | Example Output 7 | Input: 5 8 | -5 9 | -4 10 | -3 11 | -2 12 | -1 13 | 1 14 | 2 15 | 3 16 | 4 17 | 5 18 | Constraints 19 | 20 | Handle invalid inputs (non-integer, negative). 21 | Use a for loop with range(). -------------------------------------------------------------------------------- /Exercise 24: arguments.md: -------------------------------------------------------------------------------- 1 | Exercise: Anagrams 2 | Please write a function named anagrams, which takes two strings as arguments. 3 | The function returns True if the strings are anagrams of each other. 4 | Two words are anagrams if they contain exactly the same characters. 5 | Some examples of how the function should work: 6 | print(anagrams("tame", "meta")) # True 7 | print(anagrams("tame", "mate")) # True 8 | print(anagrams("tame", "team")) # True 9 | print(anagrams("tabby", "batty")) # False 10 | print(anagrams("python", "java")) # False -------------------------------------------------------------------------------- /Exercise 2: Temperature Check.md: -------------------------------------------------------------------------------- 1 | ### Exercise: Temperature Check 2 | 3 | Write a program that asks the user for the temperature (as an integer). Based on the temperature, the program should print warnings or messages according to the following conditions: 4 | - If the temperature is below **0**, print **"It's freezing!"**. 5 | - If the temperature is below **10**, print **"It's cold!"**. 6 | - If the temperature is below **20**, print **"It's cool!"**. 7 | 8 | After printing all the applicable warnings or messages, end with **"Stay safe!"**. 9 | 10 | #### Sample Output 1: 11 | ``` 12 | Please type in the temperature: -5 13 | It's freezing! 14 | It's cold! 15 | It's cool! 16 | Stay safe! 17 | ``` 18 | 19 | #### Sample Output 2: 20 | ``` 21 | Please type in the temperature: 8 22 | It's cold! 23 | It's cool! 24 | Stay safe! 25 | ``` 26 | 27 | #### Sample Output 3: 28 | ``` 29 | Please type in the temperature: 15 30 | It's cool! 31 | Stay safe! 32 | ``` 33 | 34 | #### Sample Output 4: 35 | ``` 36 | Please type in the temperature: 25 37 | Stay safe! 38 | ``` 39 | 40 | --- 41 | 42 | This exercise practices: 43 | 1. Conditional execution to check multiple ranges. 44 | 2. Cumulative messaging based on progressively tighter conditions. 45 | 3. Input and output handling in Python. -------------------------------------------------------------------------------- /Exercise 3: Exercise- Discount Calculation.md: -------------------------------------------------------------------------------- 1 | ### Exercise: Discount Calculation 2 | 3 | Write a program that asks for the total amount of a purchase, the number of items, and the day of the week. The program should then print the total price after applying a discount: 4 | - On **weekdays (Monday to Friday)**, apply a **10% discount**. 5 | - On **weekends (Saturday and Sunday)**, apply a **20% discount**. 6 | 7 | If there are more than **5 items**, apply an additional **5% discount**. 8 | 9 | #### Sample Output 1: 10 | ``` 11 | Total amount: 150 12 | Number of items: 3 13 | Day of the week: Wednesday 14 | Total price after discount: 135.0 dinars 15 | ``` 16 | 17 | #### Sample Output 2: 18 | ``` 19 | Total amount: 200 20 | Number of items: 6 21 | Day of the week: Saturday 22 | Total price after discount: 150.0 dinars 23 | ``` 24 | 25 | #### Sample Output 3: 26 | ``` 27 | Total amount: 80 28 | Number of items: 2 29 | Day of the week: Sunday 30 | Total price after discount: 64.0 dinars 31 | ``` 32 | 33 | #### Sample Output 4: 34 | ``` 35 | Total amount: 120 36 | Number of items: 4 37 | Day of the week: Tuesday 38 | Total price after discount: 108.0 dinars 39 | ``` -------------------------------------------------------------------------------- /Exercise 4: Determine the Oldest Age.md: -------------------------------------------------------------------------------- 1 | ### Exercise: Determine the Oldest Age 2 | 3 | Write a program that asks for the ages of two people. The program should then print out which person is older. If their ages are the same, the program should print a different message. 4 | 5 | #### Sample Output 1: 6 | ``` 7 | Please type in the age of the first person: 25 8 | Please type in the age of the second person: 30 9 | The older age is: 30 10 | ``` 11 | 12 | #### Sample Output 2: 13 | ``` 14 | Please type in the age of the first person: 40 15 | Please type in the age of the second person: 35 16 | The older age is: 40 17 | ``` 18 | 19 | #### Sample Output 3: 20 | ``` 21 | Please type in the age of the first person: 22 22 | Please type in the age of the second person: 22 23 | Both people are the same age! 24 | ``` 25 | 26 | --- 27 | 28 | This exercise helps reinforce: 29 | 1. Input handling for multiple values. 30 | 2. Basic comparison logic. 31 | 3. Using conditional statements to handle multiple outcomes. -------------------------------------------------------------------------------- /Exercise 5: Determine the Faster Runner.md: -------------------------------------------------------------------------------- 1 | ### Exercise: Determine the Faster Runner 2 | 3 | Write a program that asks for the names and times (in seconds) of two runners. The program should then print out the name of the faster runner. If their times are the same, the program should print a different message. 4 | 5 | #### Sample Output 1: 6 | ``` 7 | Runner 1: 8 | Name: Sarah 9 | Time (in seconds): 12.5 10 | Runner 2: 11 | Name: Michael 12 | Time (in seconds): 11.8 13 | The faster runner is Michael 14 | ``` 15 | 16 | #### Sample Output 2: 17 | ``` 18 | Runner 1: 19 | Name: Lisa 20 | Time (in seconds): 14.2 21 | Runner 2: 22 | Name: John 23 | Time (in seconds): 14.2 24 | Lisa and John have the same time 25 | ``` 26 | 27 | #### Sample Output 3: 28 | ``` 29 | Runner 1: 30 | Name: Emily 31 | Time (in seconds): 9.8 32 | Runner 2: 33 | Name: Alex 34 | Time (in seconds): 10.3 35 | The faster runner is Emily 36 | ``` 37 | 38 | This exercise practices: 39 | 1. Input handling for names and numeric data. 40 | 2. Comparing values to determine the outcome. 41 | 3. Handling cases where the values are the same. 42 | -------------------------------------------------------------------------------- /Exercise 6: Separating Dinars and Centimes: -------------------------------------------------------------------------------- 1 | ### **Exercise 06: Separating Dinars and Centimes**: 2 | Write a program that asks the user for a price in dinars and then separates the dinars (integer part) and centimes (decimal part). Assume the input is always a positive floating-point number. 3 | 4 | **Example Output 1**: 5 | ``` 6 | Please type in a price: 45.75 7 | Dinars: 45 8 | Centimes: 75 9 | ``` 10 | 11 | **Example Output 2**: 12 | ``` 13 | Please type in a price: 19.3 14 | Dinars: 19 15 | Centimes: 30 16 | ``` -------------------------------------------------------------------------------- /Exercise 7: Leap Year Exercise.md: -------------------------------------------------------------------------------- 1 | # Leap Year Exercise 2 | 3 | Write a program that asks the user for a year, then prints out whether that year is a leap year or not. 4 | 5 | ### Leap Year Rules: 6 | - A year is a leap year if it is divisible by 4. 7 | - However, if the year is divisible by 100, it is only a leap year if it is also divisible by 400. 8 | 9 | ### Sample Outputs 10 | 11 | **Input:** 12 | Please type in a year: 2011 13 | **Output:** 14 | That year is not a leap year. 15 | 16 | **Input:** 17 | Please type in a year: 2020 18 | **Output:** 19 | That year is a leap year. 20 | 21 | **Input:** 22 | Please type in a year: 1800 23 | **Output:** 24 | That year is not a leap year. 25 | -------------------------------------------------------------------------------- /Exercise 8: FizzBuzz Exercise.md: -------------------------------------------------------------------------------- 1 | # FizzBuzz Exercise 2 | 3 | Write a program that asks the user for an integer number. If the number is divisible by three, the program should print out "Fizz". If the number is divisible by five, the program should print out "Buzz". If the number is divisible by both three and five, the program should print out "FizzBuzz". 4 | 5 | ### Sample Outputs 6 | 7 | **Input:** 8 | Number: 9 9 | **Output:** 10 | Fizz 11 | 12 | **Input:** 13 | Number: 7 14 | **Output:** 15 | [No Output] 16 | 17 | **Input:** 18 | Number: 20 19 | **Output:** 20 | Buzz 21 | 22 | **Input:** 23 | Number: 45 24 | **Output:** 25 | FizzBuzz 26 | -------------------------------------------------------------------------------- /Exercise 9: Name Length Kingdom.md: -------------------------------------------------------------------------------- 1 | In a magical world, the population of a city is determined by the length of its name. 2 | For every letter in the city name, the city gains 1 million citizens. For example: 3 | 4 | The city "Paris" has 5 letters, so its population is 5,000,000. 5 | The city "New York" has 8 letters, so its population is 8,000,000. 6 | 7 | Your task is to write a program in Python that: 8 | 9 | Asks the user to input the names of several cities (one by one). This phase stop when the user tape stop as a name of a city. 10 | Calculates the population for each city based on the length of its name. 11 | Sorts the cities by their population from largest to smallest. 12 | Prints the cities and their populations in order. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Python Practice Exercises 2 | 3 | This repository contains a collection of Python exercises designed to help students improve their programming skills. The exercises cover various topics, including: 4 | 5 | - **Basic syntax and control structures** 6 | - **Functions and modules** 7 | - **Data structures (lists, tuples, dictionaries, sets)** 8 | - **File handling** 9 | - **Object-oriented programming** 10 | - **Error handling and debugging** 11 | 12 | Each exercise is designed to be practical and engaging, with varying levels of difficulty to suit beginners as well as intermediate learners. 13 | 14 | ## How to Use 15 | 16 | 1. Clone the repository: 17 | ```bash 18 | git clone https://github.com/orochiwolf/ENG3-Python-Exercices.git 19 | ``` 20 | 2.Navigate to the exercise folders and complete the tasks in the provided files. 21 | Check your solutions with the expected outputs or notes in the exercises. 22 | 23 | Feel free to contribute your solutions or suggest new exercises! 24 | --------------------------------------------------------------------------------