Python contd
Variables
- Refer Here for variables
# Variable
a = 5
# type hinting
a:int = 5
b = 5.0
# type hinting
b:float = 5.0
c = "hello"
# type hinting
c:str = "hello"
Operators
- Refer Here for operators
- Refer Here
Python indentation
- Block: Block in python refers to one or more lines of code
- Refer Here for indentation
conditionals
- Conditionally execute blocks of code
- if
if <condition>:
....
....
- if else
if <condition>:
....
....
else:
...
...
- if else if
if <condition>:
....
....
elif <condition>:
....
....
elif <condition>:
....
....
elif <condition>:
....
....
else:
...
...
loops
- Execute block of code in a loop (multiple times)
- while
while <condition>:
.....
.....
.....
- Example
index:int = 1
max:int = 5
while index <= max:
print(index)
#index = index + 1
index += 1
-
Refer Here for the notebook
-
Create an account in hackerrank as a developer and choose python
