0% found this document useful (0 votes)
2 views3 pages

Assignment Flow of Control

The document contains a series of programming exercises focused on control flow, including conditional statements and loops. Each question prompts the user to write a specific program, such as checking if a number is positive, printing a range of numbers, or calculating factorials. The exercises cover various programming concepts like if statements, loops, and functions.

Uploaded by

RAJAT BOSE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Assignment Flow of Control

The document contains a series of programming exercises focused on control flow, including conditional statements and loops. Each question prompts the user to write a specific program, such as checking if a number is positive, printing a range of numbers, or calculating factorials. The exercises cover various programming concepts like if statements, loops, and functions.

Uploaded by

RAJAT BOSE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Control Flow Questions

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.

Question 2: if-else Statement

Write a program that asks the user to input a number and prints whether the number is
positive or negative.

Question 3: if-elif-else Statement

Write a program that asks the user to input a number and prints whether the number is
positive, negative, or zero.

Question 4: Nested if Statement

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.

Question 6: while Loop

Write a program that prints all the numbers from 1 to 10 using a while loop.

Question 7: Nested Loops


Write a program that prints a 5x5 grid of asterisks (*) using nested loops.

Question 8: break Statement

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.

Question 9: continue Statement

Write a program that prints all the numbers from 1 to 10 except 5 using a for loop and
continue statement.

Question 10: pass Statement

Write a program that defines an empty function using the pass statement.

Question 11: Combining Loops and Conditionals

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.

Question 12: Factorial Calculation

Write a program that calculates the factorial of a number input by the user using a while
loop.

Question 13: Sum of Digits

Write a program that calculates the sum of the digits of a number input by the user using a
while loop.

Question 14: Prime Number Check


Write a program that checks if a number input by the user is a prime number using a for
loop.

Question 15: Fibonacci Sequence

Write a program that prints the first n Fibonacci numbers, where n is input by the user.

You might also like