Data types, Variables, and Operators
Data Types, Variables, and Operators A. Data Types: A data type defines the type of a variable. For example: Integer: Stores whole numbers like...
Data Types, Variables, and Operators A. Data Types: A data type defines the type of a variable. For example: Integer: Stores whole numbers like...
A. Data Types:
A data type defines the type of a variable. For example:
Integer: Stores whole numbers like 12, 34, 56.
Float: Stores decimal numbers like 3.14, 4.56, 6.78.
String: Stores text like "Hello", "World", "Python".
Boolean: Stores True or False values.
B. Variables:
A variable is a named memory location that stores a specific data type. We declare a variable with the = sign:
python
name = "John"
age = 32
C. Operators:
An operator is a symbol used to perform mathematical operations on variables. These operations include:
Arithmetic operators: + for addition, - for subtraction, * for multiplication, / for division.
Logical operators: == for equality check, != for inequality check, and for logical AND, or for logical OR.
Comparison operators: >, <, >=, <= for comparing two values.
Examples:
python
num1 = 10
num2 = 25
print(num1 + num2) # Output: 35
python
name = "John"
age = 32
print(name == "John") # Output: True
print(age >= 20) # Output: True
python
score = 85
if score >= 80:
print("Congratulations!") # Output: Congratulations!
By understanding data types, variables, and operators, you can write clear and concise Python code to analyze and manipulate data in a business context