Assignment Flow of Control
Assignment Flow of Control
Conditional Statements
Question 1: Simple if Statement
Write a program that asks the user to input a number and prints whether the number is
positive.
Write a program that asks the user to input a number and prints whether the number is
positive or negative.
Write a program that asks the user to input a number and prints whether the number is
positive, negative, or zero.
Write a program that asks the user to input a number and prints whether the number is
positive and even, positive and odd, or negative.
Loops
Question 5: for Loop
Write a program that prints all the numbers from 1 to 10 using a for loop.
Write a program that prints all the numbers from 1 to 10 using a while loop.
Write a program that asks the user to input numbers until they input 0. The program should
print the sum of all the input numbers.
Write a program that prints all the numbers from 1 to 10 except 5 using a for loop and
continue statement.
Write a program that defines an empty function using the pass statement.
Write a program that asks the user to input a number and prints all the even numbers from 1
to that number using a for loop.
Write a program that calculates the factorial of a number input by the user using a while
loop.
Write a program that calculates the sum of the digits of a number input by the user using a
while loop.
Write a program that prints the first n Fibonacci numbers, where n is input by the user.