{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Please \"Copy & Edit\" this notebook to your profile and write your solutions in each cell.","metadata":{}},{"cell_type":"markdown","source":"> Based on notebook: [Dive into Python-Section 1](https://www.kaggle.com/code/rouzbeh/dive-into-python-section-1) ","metadata":{}},{"cell_type":"markdown","source":"## Python Syntax and Variables","metadata":{}},{"cell_type":"markdown","source":"#### Q1: Write a program to print `\"Hello, World!\"` to the console.","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19"}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q2: Try printing the following:  \n\n>     She said, \"Python is awesome!\"  \n>     \n>     It's a beautiful day.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q3: Create a variable named `age` and set it to `25`. Print the value of age.\n","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q4: Write a program that assigns two numbers to variables and performs `addition`, `subtraction`, `multiplication`, and `division`. Finally, print all of them.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q5: Create two string variables, `first_name` and `last_name`, and `concatenate` them with a space in between.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q6: Create a variable of type `int`, `float`, and `str`, and print their `types`.\n","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q7: Given a string `\"Hello, Python!\"`, use string methods to:  \n\n>     1. Convert the string to uppercase.  \n>     \n>     2. Find the length of the string.  \n>     \n>     3. Replace \"Python\" with \"World\".","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q8: Create two boolean variables, `is_delicious` and `is_healthy`. Write a program that uses logical operators `(and, or, not)` to print the results of different combinations.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q9: Create a simple calculator program that asks the user to `input` two numbers and choose an arithmetic operation `(+, -, *, /)`. Perform the selected operation and print the result.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q10: Write a program that checks whether a number is `positive`, `negative`, or `zero`.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Data Structures","metadata":{}},{"cell_type":"markdown","source":"#### Q11: Create a `list` named fruits that contains the following items: `\"apple\", \"banana\", \"cherry\", and \"orange\"`.  \n\n#### Q12: Print the entire list and access the second element `(\"banana\")` using its index.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q13: Given a list `numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]`  \n\n#### Q14: Create a new list that contains only the `even numbers` using slicing.  \n\n#### Q15: `Reverse` the list using slicing.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q16: Create a `list` named animals containing `\"cat\", \"dog\", and \"bird\"`.  \n\n#### Q17: Add `\"fish\"` to the end of the list.  \n\n#### Q18: Insert `\"horse\"` at the second position.  \n\n#### Q19: Remove `\"dog\"` from the list.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q20: Create a `dictionary` named student with `keys: \"name\", \"age\", and \"grade\"`. The values should be `\"Sara\", 20, and \"A\"`, respectively.  \n\n#### Q21: Access and print the student's name.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q22: Add a new key-value pair to the student dictionary: `\"major\"` with value `\"Computer Science\"`.  \n\n#### Q23: Update the `\"grade\"` to `\"A+\"`.  \n\n#### Q24: Remove the `\"age\"` key from the dictionary.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q25: Create a `tuple` named dimensions with the values `(1920, 1080)`.  \n\n#### Q26: Access and print the width `(1920)`.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q27: `Unpack` the dimensions tuple into two variables: `width` and `height`, then print both.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q28: Create a `set` named colors containing `\"red\", \"green\", and \"blue\"`.  \n\n#### Q29: Add `\"yellow\"` to the set.  \n\n#### Q30: Remove `\"green\"` from the set.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q31: Given two sets, `set1 = {1, 2, 3}` and `set2 = {3, 4, 5}`, find the `union`, `intersection`, and `difference` of the two sets.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Control Structures","metadata":{}},{"cell_type":"markdown","source":"#### Q32: Write a program that checks if a variable number is `positive`. If it is, print `\"The number is positive.\"`","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q33: Modify the previous program to also print `\"The number is not positive\"` if the condition is false.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q34: Write a program that checks the variable grade and prints different messages based on its value:\n\n>     \"Excellent!\" for grades above 85  \n>     \n>     \"Good job!\" for grades between 70 and 85  \n>     \n>     \"Better luck next time!\" for grades below 70","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q35: Write a program that prints all numbers from `1 to 5` using a for `loop`.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q36: Create a list of names and print each name using a for `loop`.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q37: Write a program that uses a `while loop` to print numbers from `1 to 5`.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q38: Write a program that continuously asks the user for a number and prints it if it's `even`. The program should `stop` if the user inputs the `number 10`.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q39: Write a program that `sums even numbers` from a predefined list data and prints the result.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Introduction to Functions","metadata":{}},{"cell_type":"markdown","source":"#### Q40: Write a `function` greet that takes a name as an argument and prints a `greeting message`.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q41: Create a `function square` that takes a number as an argument and returns its square.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q42: Write a `function power` that takes two arguments, `base` and `exponent`, with a default value of 2 for exponent. The function should return the result of raising base to the power of exponent.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q43: Write a `function calc` that takes two numbers as arguments and returns both their `sum` and `product`.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q44: Create a `function minmax` that normalizes a list of numbers to a specified range `[a, b]`.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q45: Write a `function count_vowels` that takes a string as an argument and returns the number of `vowels` in that string.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q46: Write a `function is_prime` that checks if a number is prime. It should return True if the number is `prime` and False otherwise.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Q47: Write a `function find_max` that takes a list of numbers and returns the `maximum value` in that list.","metadata":{}},{"cell_type":"code","source":"# Your code...","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Wishing you the best!","metadata":{}}]}