Let’s learn the basics of Python, one of the most popular programming languages in the world.
In the end, we’ll be creating a simple app to calculate your shopping cost.
Let’s get started
Getting Started with Python
1. Getting Started
The Basics
2. Strings
3. Integers
4. Calculations
Variables
5. Variables
6. Using Variables
7. Updating Variables
8. String Concatenation
9. Data Types
Booleans and Conditions
10. if Statements
11. Booleans
12. else Statements
13. elif Statements
14. Combining Conditions
The Shopping App
15. Calculating Prices
16. Getting Input
17. Control Flow
Start Learning
1) About Python
Python is a programming language that is simple and easy to understand. It is used in Web development, machine learning, statistic processing, and more.
2) String
Let’s Print Characters
Let’s run our first Python program! You can display characters by using print(). Characters inside the parentheses will be displayed in the console.
In Python, a sequence of characters, like “Hello Python”, is called a string. A string needs to be enclosed in single ‘ or double ” quotes. The output will be the same either way. If you don’t put it in quotes, you will get an error.
Comments
Adding # at the beginning will make the entire line a comment.
Comments will not be executed when running code, so you can use them to leave notes.
3) Integers
You can use numbers like integers in programming. Unlike strings, they don’t need to be enclosed in quotes. You can add and subtract integers just like you do in math. The spaces before and after operators are not required, but they will make the code easier to read.
Difference between Strings and Integers
Strings and integers are interpreted differently in programming. Like the images below, 3 + 5 will print 8, which is the result of the addition. However, if you enclose it in quotes and make it a string, the output will stay as 3 + 5.
4) Calculations
More Calculations
In Python, you can do other calculations like multiplication and division, but with different symbols from what you would use in math. * is for multiplication and / is for division. You can also calculate the remainder of a division using %.
continue……..