Do you want a video, or is this okay?
Anonymous Poll
33%
Yes! video for better understanding
67%
No... this ok
Day 2 ✅
On yesterday's session we talked about on how to setup python and run it on local machine and at the end we executed a simple python code called print.
the code
is used to show the text in the quotation mark to be shown on the terminal. the whole text shown above is called STATEMENT.
Today We are going to see about VARIABLES in python
VARIABLES in python are Containers that store information. think of them like labeled boxes:
Here
and
are labels
and
are the stored values
There are certain rules in naming a variable or variables
✔️ Must start with a letter
✔️ Cannot start with a number
✔️ No spaces (use _ instead)
✔️ Case-sensitive (Age ≠ age)
✔️ Avoid reserved words (like for, if, class)
Example
On yesterday's session we talked about on how to setup python and run it on local machine and at the end we executed a simple python code called print.
the code
print("Heloooo")is used to show the text in the quotation mark to be shown on the terminal. the whole text shown above is called STATEMENT.
Today We are going to see about VARIABLES in python
print("What are Variables in Python?")VARIABLES in python are Containers that store information. think of them like labeled boxes:
name = "Abebe"
age = 21
Here
name
and
age
are labels
"Abebe"
and
21
are the stored values
There are certain rules in naming a variable or variables
✔️ Must start with a letter
✔️ Cannot start with a number
✔️ No spaces (use _ instead)
✔️ Case-sensitive (Age ≠ age)
✔️ Avoid reserved words (like for, if, class)
Example
first_name = "Kebede"
userAge = 20
🥰3🔥2👏1
Forwarded from INSA Cyber Talent Center
✅ Day 3
Python Data Types
These determine what kind of data a variable holds.
🔹 String (str) – text
🔹 Integer (int) – whole numbers
🔹 Float (float) – decimal numbers
🔹 Boolean (bool) – True/False
Python Data Types
These determine what kind of data a variable holds.
🔹 String (str) – text
name = "John"
🔹 Integer (int) – whole numbers
age = 25
🔹 Float (float) – decimal numbers
height = 5.9
🔹 Boolean (bool) – True/False
is_student = True
Checking Data Types
Use
to see the type of a variable:
Use
type()
to see the type of a variable:
x = 10
print(type(x)) # <class 'int'>
Changing Data Types (Type Casting)
age = "20"
age = int(age) # convert string to int
Mini-Exercise for you guys
✏️ Task:
Create variables to store:
your name
your age
your height
whether you are a student
Then print them out.
Example:
✏️ Task:
Create variables to store:
your name
your age
your height
whether you are a student
Then print them out.
Example:
name = "Marta"
age = 18
height = 1.65
is_student = True
print(name)
print(age)
print(height)
print(is_student)
🔥4
if you guys are struggling on how to solve it refer to DAY 3 for additional information 👆
✅DAY 4
Python Operators & Basic Expressions
Operators are symbols that tell Python to perform an action.
Example:
Arithmetic Operators
Used for math operations:
Example
Python Operators & Basic Expressions
print("What Are Operators?")Operators are symbols that tell Python to perform an action.
Example:
a = 10
b = 5
print(a + b)
Arithmetic Operators
Used for math operations:
+ ———> Addition ——> 5 + 2
- ———> Subtraction —-> 5-2
* ———> Multiplication —> 5 * 2
/ ———-> Division ———-> 5/2
// ———> Floor Division —> 5 // 2
% ———> Modulus (remainder) —> 5 % 2
** ———> Power ————> 5 ** 2
Example
x = 7
y = 3
print(x*y)
Comparison Operators
They compare two values and return True or False.
They compare two values and return True or False.
== equal to
!= not equal
> greater than
< less than
>= greater or equal
<= less or equal
👏2
Logical Operators
Used to combine conditions:
Used to combine conditions:
and both conditions must be true
or at least one condition must be true
not reverses a condition
Assignment Operators
Used to update Variables:
Used to update Variables:
x = 10
x += 5 # x = x + 5
x -= 2 # x = x - 2
x *= 3
x /= 2
Mini Practice Tasks
Task A
Create two numbers and print:
their sum
their difference
their product
their remainder
Task B
Ask the user for age and check if they are above 18:
Task A
Create two numbers and print:
their sum
their difference
their product
their remainder
Task B
Ask the user for age and check if they are above 18:
Hint: Use The input() Function to accept the age:
print("After You done these tasks Try to Build a Simple Calculator Using the Arithmetic and Conditional Operators")