Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

-Control-Structures-in-Python

Control structures determine how the flow of execution moves through your Python program. They help you make decisions, repeat actions, and control the logic of your code. Conditional Statements (Decision Making) num % 2 → gives the remainder when num is divided by 2.

If the remainder is 0, the number is even.

Otherwise, it’s odd. Q1) n = int(input("Enter a number: ")) if n % 2==0: print(f"{n} is an even number") else: print(f"{n} is an odd number") Output: Enter a number: 7 7 is an odd number Enter a number: 12 12 is an even number

Q2) total_sum = sum(range(1, 51)) print(f"The sum of numbers from 1 to 50 is: {total_sum}") Output: The sum of numbers from 1 to 50 is: 1275

About

Control structures determine how the flow of execution moves through your Python program. They help you make decisions, repeat actions, and control the logic of your code.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages