Review of Python: Data types, operators, flow control
Review of Python: Data types, operators, flow control Data types A data type is a specific format that a number is stored in. In Python, there are severa...
Review of Python: Data types, operators, flow control Data types A data type is a specific format that a number is stored in. In Python, there are severa...
Data types
A data type is a specific format that a number is stored in. In Python, there are several built-in data types:
Integers: Whole numbers like 1, 2, 3, 4, 5
Floats: Numbers with decimal points like 1.23, 2.34, 3.14
Strings: Text enclosed in double quotes like "Hello", "World", "Python"
Booleans: True or False values
Operators
Operators are used to perform calculations on data. There are basic operators like addition (+), subtraction (-), multiplication (*), division (/), and comparison operators (==, !=).
Flow control
Flow control statements allow you to control the flow of your program based on certain conditions. These include:
If statements: if condition: code to execute
While loops: while condition: code to execute
For loops: for variable in range(start, stop): code to execute
Example:
python
age = int(input("Enter your age: "))
salary = float(input("Enter your salary: "))
if age >= 18:
print("You are eligible to work.")
for i in range(5):
print(i)
This example demonstrates how to define data types, operators, and flow control in Python. It then uses these concepts to perform different operations and achieve a specific outcome