|
| 1 | +<h1 align="center">Introduction to Python</h1> |
| 2 | +<hr> |
| 3 | + |
| 4 | +<div align="center" style="display: flex;"> |
| 5 | + <img src="https://i.gifer.com/XOsX.gif" height="64px" align="center"> |
| 6 | + <h2 align="center">So What is Python</h2> |
| 7 | + <img src="https://i.gifer.com/XOsX.gif" height="64px"> |
| 8 | + </div> |
| 9 | +</div> |
| 10 | + |
| 11 | +<br /> |
| 12 | + |
| 13 | +<div align="center"> |
| 14 | +<img src="assets/python_logo.png" alt="Python_Logo" height="100px"/> |
| 15 | +</div> |
| 16 | + |
| 17 | +- Python is a **[high-level programming language](https://en.wikipedia.org/wiki/High-level_programming_language)**, which means it is user-friendly and easy for programmers to understand and learn. Python is renowned for its readability and ease of use. It is utilized in various fields, including web development, data analysis, machine learning, and more. |
| 18 | + |
| 19 | + |
| 20 | +#### Python Coding Environment |
| 21 | + |
| 22 | +<img src="assets/code_editor.PNG" alt="VSCode" height="500px"/> |
| 23 | + |
| 24 | +<br /> |
| 25 | +<br /> |
| 26 | + |
| 27 | +- There are many popular IDEs and code editors, such as IDLE, Visual Studio Code, and PyCharm, but we will be using Visual Studio Code. |
| 28 | + |
| 29 | +- If you haven't set up VSCode and Python yet, please [follow this tutorial.](https://youtu.be/zk5qOQBvuK4?si=TTp-ot2_VN6lorua) |
| 30 | + |
| 31 | +<hr> |
| 32 | + |
| 33 | +<div style="display: flex; justify-content: center;"> |
| 34 | + <div style="display: flex; align-items: center; justify-content: center; gap: 1rem; border: 1px solid white; width: fit-content;"> |
| 35 | + <img src="https://i.gifer.com/XOsX.gif" height="64px"> |
| 36 | + <h2 align="center">Printing</h2> |
| 37 | + <img src="https://i.gifer.com/XOsX.gif" height="64px"> |
| 38 | + </div> |
| 39 | +</div> |
| 40 | + |
| 41 | +<br> |
| 42 | + |
| 43 | +Printing in Python refers to the process of displaying text or data on the screen, typically in the console or terminal. |
| 44 | +In Python, you can use the `print()` function to output information, messages, variables, or any content you want to see during the program's execution. |
| 45 | + |
| 46 | +Here's how printing works in Python: |
| 47 | + |
| 48 | +The `print()` function: |
| 49 | +- Used for printing text and values to the console |
| 50 | +- You can print text by enclosing it in either single quotes `' '`, double quotes `" "`, or triple quotes `''' '''` or `""" """` |
| 51 | + |
| 52 | +```Python |
| 53 | +# single quotes |
| 54 | +print('Department of Software and Web Development ૮꒰ ˶• ༝ •˶꒱ა ♡') |
| 55 | + |
| 56 | +# double quotes |
| 57 | +print("Department of Software and Web Development ૮꒰ ˶• ༝ •˶꒱ა ♡") |
| 58 | + |
| 59 | +# triple quotes (for multi-line strings) |
| 60 | +print("""Department of \ |
| 61 | +Software and Web Development \ |
| 62 | +૮꒰ ˶• ༝ •˶꒱ა ♡""") |
| 63 | +``` |
| 64 | + |
| 65 | +Output: |
| 66 | + |
| 67 | +``` |
| 68 | +Department of Software and Web Development ૮꒰ ˶• ༝ •˶꒱ა ♡ |
| 69 | +Department of Software and Web Development ૮꒰ ˶• ༝ •˶꒱ა ♡ |
| 70 | +Department of Software and Web Development ૮꒰ ˶• ༝ •˶꒱ა ♡ |
| 71 | +``` |
| 72 | + |
| 73 | +- You can format the printed output by using the following escape characters: |
| 74 | +`\n`: Inserts a new line. |
| 75 | +`\t`: Inserts a tab. |
| 76 | +`\"` or `\'`: Escapes double or single quotes within a string. |
| 77 | + |
| 78 | +```Python |
| 79 | +print("Line 1\nLine 2") |
| 80 | +print("Tabbed\tText") |
| 81 | +print("\"Hello\" World!") |
| 82 | +``` |
| 83 | + |
| 84 | +Output: |
| 85 | +``` |
| 86 | +Line 1 |
| 87 | +Line 2 |
| 88 | +Tabbed Text |
| 89 | +"Hello" World |
| 90 | +``` |
| 91 | + |
| 92 | + |
| 93 | +<hr> |
| 94 | + |
| 95 | +<div style="display: flex; justify-content: center;"> |
| 96 | + <div style="display: flex; align-items: center; justify-content: center; gap: 1rem; border: 1px solid white; width: fit-content;"> |
| 97 | + <img src="https://i.gifer.com/XOsX.gif" height="64px"> |
| 98 | + <h2 align="center">Variables</h2> |
| 99 | + <img src="https://i.gifer.com/XOsX.gif" height="64px"> |
| 100 | + </div> |
| 101 | +</div> |
| 102 | + |
| 103 | +<br/> |
| 104 | + |
| 105 | +```Python |
| 106 | +message = "Hello World" |
| 107 | +``` |
| 108 | + |
| 109 | +#### What are variables? |
| 110 | + |
| 111 | +Variables are symbolic names used to store data. They are essential for data storage, flexibility, code readability, reusability, and data transformation in software development. |
| 112 | + |
| 113 | +When naming variables, it's important to use descriptive names that follow conventions such as using meaningful words, `camelCase` or `snake_case`, avoiding reserved words, and being consistent in your naming style. Proper variable naming enhances code readability and maintainability. |
| 114 | + |
| 115 | +#### Variable Assignment |
| 116 | + |
| 117 | +```Python |
| 118 | +message = "Hello world!" |
| 119 | +random_word = "Software" |
| 120 | +birth_month = "March" |
| 121 | +year_born = 2004 |
| 122 | +is_handsome = True |
| 123 | +``` |
| 124 | + |
| 125 | +Python doesn't require you to specify the type of each variables you declare. |
| 126 | + |
| 127 | +This is possible because Python is doing it through a process called [type inference](https://en.wikipedia.org/wiki/Type_inference). <sup>*(While it's not necessary for you to fully understand it, it's never a bad thing that you're aware it exists.)*</sup> |
| 128 | + |
| 129 | +The value of a variable can also be changed, here is an example: |
| 130 | + |
| 131 | +```Python |
| 132 | +message = "Hello World!" |
| 133 | +print(message) |
| 134 | +message = "Hi" |
| 135 | +print(message) |
| 136 | +``` |
| 137 | + |
| 138 | +Output: |
| 139 | +``` |
| 140 | +Hello World! |
| 141 | +Hi |
| 142 | +``` |
| 143 | + |
| 144 | +Printing Using Variables: |
| 145 | +- There are lots of ways we can print variables but we will be focusing on `f-strings`: |
| 146 | + |
| 147 | +```Python |
| 148 | +my_name = "John" |
| 149 | +print(f"Hello, I am {my_name}. Have a wonderful day!") |
| 150 | +``` |
| 151 | +Output: |
| 152 | +``` |
| 153 | +Hello, I am John. Have a wonderful day! |
| 154 | +``` |
| 155 | + |
| 156 | +F-strings are a way to create dynamic and readable text in Python. |
| 157 | + |
| 158 | +You can put variables and expressions inside curly braces `{}` within a string, and Python will fill in the values when the string is created. This makes it easy to generate text that changes based on data or calculations. F-strings start with `f` or `F` and are a handy feature for making your code more readable and efficient. |
| 159 | + |
| 160 | +<hr> |
| 161 | + |
| 162 | +<div style="display: flex; align-items: center; justify-content: center; gap: 1rem; border: 1px solid white;"> |
| 163 | +<img src="https://i.gifer.com/6tXM.gif" height="64px"/> |
| 164 | +<h1 align="center">CHALLENGE TIME!!!</h1> |
| 165 | +<img src="https://i.gifer.com/6tXM.gif" height="64px"/> |
| 166 | +</div> |
| 167 | + |
| 168 | +<br> |
| 169 | + |
| 170 | +Based on this output try to recreate it using what you have learned today! Remember to not just print the whole thing, use variables for good practice. Replace the curly braces with whatever you like as long as it is not inappropriate. You may add more if you like. |
| 171 | + |
| 172 | +The output should look like this: |
| 173 | + |
| 174 | +``` |
| 175 | +Hello, I am {your_name}. I love {name_of_department} and I love being in the Backend even more! |
| 176 | +One thing about me is that {about_you}. |
| 177 | +``` |
0 commit comments