Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# LAB_LOOPS


## 1) Using range(), make a range from 45 to 210, using a for loop iterate over the sequence and print the elements. Skip the number 100 and break the loop at 205
## 1) Using range(), make a range from 45 to 210, using a for loop iterate over the sequence and print the elements. Skip the number 100 and break the loop at 205

## 2) Using a while loop and input , do the following :
- Ask the the user : "what is the product of 7 * 24 ?"
- check if the answer is right then exit the loop and print "You answered this Question correctly"
- if the answer is wrong, then print "Your Answer is wrong try again.." and show the user the question again.

- Ask the the user : "what is the product of 7 \* 24 ?"
- check if the answer is right then exit the loop and print "You answer this question correctly""
- if the answer is wrong, then print "Your Answer is wrong try again.." and show the user the question again.

## Bonus

Expand All @@ -16,7 +15,6 @@
Write a Python program that prompts the user for a positive integer `n`, and then calculates the sum of all even numbers between 1 and `n`, inclusive.

Your program should use a loop (either a `for` loop or a `while` loop) to iterate over the numbers between 1 and `n`, and only add the even numbers to the sum.

For example:

```
Expand Down
7 changes: 7 additions & 0 deletions bouns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
number = int(input("Enter a positive number?"))
total = 0
for num in range (1, number+1):
if num % 2 == 0:
total += num

print ("the sum of even number between 1 and", number , "is", total)
16 changes: 16 additions & 0 deletions lab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
for num in range (45,211):
if num == 100:
continue
if num == 205:
break
print (num)


while True:
answer = int(input("what is the product of 7*24?"))
if answer == 7*24:
print ("You answer this question correctly")
break
else:
print("Your Answer is wrong try again..")