Python Test - If-Else Statements and Loops
Python Test - If-Else Statements and Loops
else:
Sai Zeya Phone Myint print("The number is negative")
elif num <0:
William Soe print("Your
print("Yournumber
number is negative")
is zero")
Lin Myat Paing elfi num >1:
Grace Htun print("Number
print("Your is positive")
number is zero.")
Yunn Yunn Shwe Yee Htut else:
Bhone Myint Myat print("Your
if number = 0 number is a negative number")
Yamin Oline Htun-Hansen print("this
if number =number
0 is zero")
Nelson Bo print("This number
print("Your numberis zero")
is an odd number.")
Zwe Pyae Sone Aung elif num < 0:
Sting Xiong if print("Your
num = > 0: number is negative")
Deesha Khedkar print
else: ("Negative number")
Heidi Thet Hmue Hay Thi Htay print("Thenumber
print("The numberisiszero")
zero.")
Edgar Maung
Write a for loop that prints Points
all the
- Write
evenanumbers
for loop from
that prints
1 to 20.
all the even
Points - Write a Python program
Feedback
that
- Write
checks
a Python
if a number
program
is positive,
that checks
negative,
for numbers in (0, 21, 2) if a number
or zero is
and
positive,
prints the
negative,
appropriate
or zero message
and prinf
0 print(numbers)
print(num) 0
0 for num in range(0, 21, 2): 0
0 print(num) 0
0 for num in range(2,21,2): 0
0 print(num)
print(num) 0
0 for counter in range(1,20): 0
0 forprint("Even: ",counter)
counter in range (0,21,2) 0
0 print
for num("Even ",counter)
in range(0,21,2): 0
0 forprint(num)
num in range (0,21,2): 0
0 print(num)
for count in range=(1,21): 0
0 if num % 2 == 0: 0
0 print(num)
for num in range (2, 21) 0
0 print("These are the even numbers") 0
Feedback - Write a for loop
Write
thata prints
Pythonallprogram
the evenusing
Points
numbers
a-while
Write
fromloop
a Python
1 to
that
20.calculates
program
Feedbackusing
the
- Write
sum
a while
of
a Python
numbers
loop that
program
from
calculates
1using
to 10.the
a whi
su
print(number1 - sum)
for num in range (0,11,2) 0
print(num)
print("total sum of 1 to 10 =", num) 0
int(input("num1", + "num2")) 0
print("Your
currentnumber + 1 to", num1 + num2) 0
is equal
= current
print("The
total sum =sum of numbers from 1 to 10 is:", sum)
counter 0
print(total sum) 0
0
print("Sum",number1+number2+number3+number4+number5+number6+number7+number8+n
print("Sum ",number1+number2+number3+number4+number5+number6+number7+number8+n
counter += 1 0
0
print("The sum of numbers from 1 to 10 is:", total_sum)
sum + = current num 0
0
print("The sum of numbers from 1 to 10 is:", sum_of_numbers)
0
0
num = 10 if num % 2 == 0:num =print("Even")
10 if num % else:
2 == print("Odd")
0:num =print("Even")
10 if num % else:
2 == print("Odd")
0:
Writeprint("Even")
a Python program
else: print("Odd")
that asks the user to en
else:
It checks if he number is e 0 else: print("You are not eligible to vote.")
The following python code 0 print("You are not eligible to vote")
else:
It checks whether the num 0 print("You are not eligible to vote.")
else:
The number is 10 and if th 0 else:print("You are not eligible to vote.")
It shows which numbers are 0 print("You are not eligible to vote.")
else:
This Python code shows if 0 else:print("You are not eligible to vote")
It tells us whether the n 0 print("You are not eligible to vote")
else
It identifies if the numbe 0 print("You
else: are not eligible to vote")
The given number is 10. I 0 print("You are not eligible to vote.")
else:
The user is told to input
if 10% of 2 = 0 it will print "Even" 0 if age < 18: are not eligible to vote")
print("You
if is is not then it will print "Odd" 0 print
else: ( "You are eligible to vote.")
The number is or equal to 0 print("You are not eligible to vote.")
else:
It finds whether the numb 0 print("You are not eligible to vote.")
Points - Write a Python program
Feedback
that
- Write
asks the
a Python
user to
program
enter their
thatage.
asksIfthe
theuser
ageto
is 18
enter
or above,
their age.
print
If the
"Youage
areiseligible
18 or above
to vo
0
0
0
0
0
0
0
0
0
0
0
0
0
r age. If the age is 18 or above, print "You are eligible to vote." Otherwise, print "You are not eligible to vote."