i = 0
for i in range(0, 100):
if i % 5 == 1:
print(f"{i} is a odd number")
else:
print(f"{i} is a even number")
i % 2
a=0
b=a
print(a)
0
What is an algorithm?
A list of steps that you can use to follow a task
my_var = 0
if my_var = 0:
print("test")
if my_var == 0
a=input("number: ")
print(a)
(whatever number the user gives)
What is a program?
An algorithm (or collection of algorithms) that has been coded into something that can be run by a machine
print("he said "the day is fine" and dies.")
print(''it's fine now. why, because i'm here'')
print("I am running away from my responsibilities. And it feels good.")
print("he said /"the day is fine/" and dies.")
print('it/'s fine now. why, because i/'m here')
index=0
for i in "hello world"
index=index+1
if index != 3:
print(i)
h
e
l
o
w
o
r
l
d
What is looping?
The act of doing something over and over again
path = "C:\Users\Dell\Desktop\Nutopia\TruthOrDebug\not-the-answers.zip"
with open(path, 'r') as file:
print(file.read())
1:
"C:\\Users\\Dell\\Desktop\\Nutopia\\TruthOrDebug\\not-the-answers.zip"
2:
r"C:\Users\Dell\Desktop\Nutopia\TruthOrDebug\not-the-answers.zip"
factorial = 1
for i in range(10):
factorial *= i
print(factorial)
0
What are conditionals?
Programs or "rewards" that only run when certain parameters are met.
my_job
def my_job()
print("i exist")
def my_job():
print("i exist")
my_job()
for i in range(10):
if i % 2 == 0:
continue
print(i)
1
3
5
7
9
Difference between For loop and while loop
In the case of for loop if the condition is not true the first time then the control will never enter a loop. In the case of a while loop if the condition is true then the loop is iterated.