Python Pioneers: A Beginner's Guide ๐Ÿ‡ช๐Ÿ‡น
8.82K subscribers
346 photos
40 videos
24 files
64 links
Welcome to Python Pioneers: Empowering Ethiopian students to embark on their coding journey.

๐Ÿ“ข Channel: @python_pioneers
๐Ÿ‘ฅ Group: @python_pioneers_chat
Download Telegram
Description for the above code

The above Python code will print the string "hello world" ten times. Here's a breakdown of how it works:

1. The for loop is set to iterate over the range from 1 to 10 inclusive. The range(1, 11) function generates a sequence of numbers starting from 1 up to (but not including) 11.

2. On each iteration of the loop, the print('hello world') statement is executed.

Because the loop iterates 10 times, "hello world" will be printed 10 times, each on a new line.

Here is the code:

for i in range(1, 11):
print('hello world')

Output
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world

#ForLoop

@python_pioneers
@python_pioneers
๐Ÿ‘4๐Ÿฅฐ2โค1
Everyone Has a Story in Life

A 24 year old boy seeing out from the trainโ€™s window shoutedโ€ฆ

โ€œDad, look the trees are going behind!โ€

Dad smiled and a young couple sitting nearby, looked at the 24 year oldโ€™s childish behavior with pity, suddenly he again exclaimedโ€ฆ

โ€œDad, look the clouds are running with us!โ€

The couple couldnโ€™t resist and said to the old manโ€ฆ

โ€œWhy donโ€™t you take your son to a good doctor?โ€ The old man smiled and saidโ€ฆโ€œI did and we are just coming from the hospital, my son was blind from birth, he just got his eyes today.โ€

Every single person on the planet has a story. Donโ€™t judge people before you truly know them. The truth might surprise you.

แˆ˜แˆแŠซแˆ แˆแˆฝแ‰ต!

#EnglishStory

@python_pioneers
@python_pioneers
โค5๐Ÿ‘1๐Ÿฅฐ1
Forwarded from TIKVAH-MAGAZINE
#แŒฅแ‰†แˆ›

แ‹จแŠขแŠ•แŽแˆญแˆœแˆฝแŠ• แˆ˜แˆจแ‰ฅ แ‹ฐแˆ…แŠ•แАแ‰ต แŠ แˆตแ‰ฐแ‹ณแ‹ฐแˆญ (แŠขแŠ•แˆณ) แ‰ แˆ€แŒˆแˆญ แŠ แ‰€แ แ‹ฐแˆจแŒƒ แŠฅแ‹ตแˆœแŠ แ‰ธแ‹ แŠจ11 แŠ แˆ˜แ‰ต แ‰ แˆ‹แ‹ญ แˆˆแˆ†แŠ‘ แŠฅแŠ“ แแˆ‹แŒŽแ‰ต แˆ‹แˆ‹แ‰ธแ‹ แ‹จแˆณแ‹ญแ‰ แˆญ แŠญแˆ…แˆŽแ‰ต แ‹จแˆตแˆแŒ แŠ“ แˆแ‹แŒˆแ‰ฃ แŠฅแŠ“ แ‹จแ‰ปแˆŒแŠ•แŒ… แˆ˜แˆญแˆƒแŒแ‰ฅแˆญ แˆ˜แŒ€แˆ˜แˆฉแŠ• แ‰ แˆฐแŒ แ‹ แŒ‹แ‹œแŒฃแ‹Š แˆ˜แŒแˆˆแŒซ แŒˆแˆแŒฟแˆแข

แ‰ฐแ‰‹แˆ™ แ‰ แˆแˆ‰แˆ แ‹จแˆ€แŒˆแˆชแ‰ฑ แŠญแแˆ แ‹ซแˆ‰ แ‹ˆแŒฃแ‰ถแ‰ฝแŠ• แˆ˜แˆ˜แ‹แŒˆแ‰ฅ แ‹จแˆšแ‰ฝแˆ‰ แˆ˜แˆ†แŠ‘แŠ• แ‹จแŒˆแˆˆแ€ แˆฒแˆ†แŠ• แ‰ แˆ€แŒˆแˆญ แŠ แ‰€แ แ‹ฐแˆจแŒƒ แ‹จแˆšแˆ˜แ‹˜แŒˆแ‰ก แˆฐแˆแŒฃแŠžแ‰ฝแŠ•  แ‹ฐแˆจแŒƒ แ‰ แ‹ฐแˆจแŒƒ แ‹จแˆšแˆ˜แˆˆแˆแˆแ‰ แ‰ต แˆแ‰ฐแŠ“ (แ‰ปแˆŒแŠ•แŒ…) แŠฅแŠ“ แŠญแˆ…แˆŽแ‰ณแ‰ธแ‹แŠ• แ‹จแˆšแˆˆแ‹ญแ‰ แ‰ต แˆณแ‹ญแŠ•แˆณแ‹Š แˆ˜แˆตแˆแˆญแ‰ต แˆ›แ‹˜แŒ‹แŒ€แ‰ฑแŠ• แ‰ฐแŒˆแˆแŒฟแˆแข

แ‰ฐแ‰‹แˆ™ แ‹จแˆšแˆฐแŒฃแ‰ธแ‹ แ‹จแˆตแˆแŒ แŠ“ แˆ˜แˆตแŠฎแ‰ฝ แˆแŠ•แ‹ตแŠ“แ‰ธแ‹ แŠ“แ‰ธแ‹?

- แ‰ แˆณแ‹ญแ‰ แˆญ แ‹ฐแˆ…แŠ•แАแ‰ตแฃ
- แ‰ แˆณแ‹ญแ‰ แˆญ แ‹ฐแˆ…แŠ•แАแ‰ต แ‹˜แˆญแ แ‹จแ‹ตแˆจแŒˆแ…แฃ แ‹จแˆ˜แ‰ฐแŒแ‰ แˆชแ‹ซ แŠฅแŠ“ แ‰ฐแ‹ซแ‹ซแ‹ฅ แˆแˆ›แ‰ต (development)แฃ
- แ‹จแˆตแˆ›แˆญแ‰ต แ•แˆฎแŒ€แŠญแ‰ต แˆฒแˆตแ‰ฐแˆžแ‰ฝ แฃ
- แ‰ แŠคแˆฎแˆตแ”แˆต แŠฅแŠ“ แˆŽแˆŽแ‰ฝแˆ แŠฅแŠ•แ‹ฐแˆ†แŠ‘ แ‰ฐแŒˆแˆแŒฟแˆแข

แˆตแˆแŒ แŠ“แ‹ แ‰ แŠ แ‹ฒแˆต แŠ แ‰ แ‰ฃ แ‹ฉแŠ’แ‰จแˆญแˆฒแ‰ฒ แ‰ดแŠญแŠ–แˆŽแŒ‚ แˆˆแŠ แŠ•แ‹ต แ‹ˆแˆญ แ‹ญแˆฐแŒฃแˆ แ‹จแ‰ฐแ‰ฃแˆˆ แˆฒแˆ†แŠ• แŠ แˆ˜แˆแŠซแ‰พแ‰ฝ แ‰ แ‹Œแ‰ฅแˆณแ‹ญแ‰ต  https://talent.Insa.gov.et แ‰ แˆ˜แŒแ‰ฃแ‰ต แŠฅแˆตแŠจ แŒแŠ•แ‰ฆแ‰ต 30/ 2016 แ‹“/แˆ แˆ˜แˆ˜แ‹แŒˆแ‰ฅ แŠฅแŠ•แ‹ตแ‰ตแ‰ฝแˆ‰ แŒฅแ‰†แˆ› แ‰€แˆญแ‰งแˆแข

แˆˆแ‰ แˆˆแŒ  แˆ˜แˆจแŒƒ +251904311833 +251943579970

+251904311837

@TikvahethMagazine
FLOW CONTROL : WHILE LOOP

แ‹›แˆฌ แˆ›แ‰ณ แŠจแ‰ฃแˆˆแˆแ‹ แ‰ตแˆแˆ…แˆญแ‰ต แ‹จแ‰€แŒ แˆˆ แ‰ Python แˆตแˆˆ While loop แŠฅแŠ•แˆ›แˆซแˆˆแŠ•แข

Stay tuned!

โฑ๏ธ 8 : 00 PM EAT

@python_pioneers
@python_pioneers
๐Ÿ‘1
What is a While Loop?

แ‹จแ‰ฐแ‹ˆแˆฐแА แˆแŠ”แ‰ณ แŠฅแ‹แАแ‰ต แŠฅแˆตแŠจแˆ†แА แ‹ตแˆจแˆต แ‰ แ“แ‹ญแ‹˜แŠ• แ‹แˆตแŒฅ แˆˆแ‰ฐแ‹ˆแˆฐแА แŒŠแ‹œ loop แ‰ แ‰ฐแ‹ฐแŒ‹แŒ‹แˆš แ‹จแŠฎแ‹ต แŠฅแŒˆแ‹ณแŠ• แ‹ญแˆแŒฝแˆ›แˆแข แŒฅแ‰…แˆ แˆ‹แ‹ญ แ‹จแˆšแ‹แˆˆแ‹ แ‹จแ‹ตแŒแŒแˆžแˆฝ แ‰ฅแ‹›แ‰ต แŠ แˆตแ‰€แ‹ตแˆž แ‰ แˆ›แ‹ญแ‰ณแ‹ˆแ‰…แ‰ แ‰ต แŒŠแ‹œ แŠฅแŠ“ แŠ แŠ•แ‹ณแŠ•แ‹ต แˆแŠ”แ‰ณแ‹Žแ‰ฝ แ‰ แˆšแˆŸแˆ‰แ‰ แ‰ต แŒŠแ‹œ แАแ‹.

While loop แ‰ Python แŠ แŠ•แ‹ตแŠ• block of code specify แ‹จแ‰ฐแ‹ฐแˆจแŒˆแ‹ condition แŠฅแ‹แАแ‰ต แŠฅแˆตแŠจแˆ†แА แ‹ตแˆจแˆต repeatedly(แ‰ แ‰ฐแ‹ฐแŒ‹แŒ‹แˆš) execute แ‹จแˆšแ‹ซแˆจแŒ แ‹จ Python flow control แŠ แ‹ญแАแ‰ต แАแ‹แข While loopแŠ• แ‹จแˆแŠ•แŒ แ‰€แˆ˜แ‹ number of iteration แˆˆแˆ›แ‹ญแ‰ณแ‹ˆแ‰…แ‰ฃแ‰ธแ‹ แ‹ˆแ‹ญแˆ executionแŠ แ‰ธแ‹ on some condition แˆ‹แ‹ญ depend แˆˆแˆšแˆ†แŠ•แ‰ฃแ‰ธแ‹ blocks of code แАแ‹แข

Syntax of While Loop

แ‹จ While loop basic syntax แ‹ญแˆ„แŠ•แŠ• แ‹ญแˆ˜แˆตแˆ‹แˆ:

while condition:
# Code block to be executed

- condition: แŠ แŠ•แ‹ต condition แŠฅแ‹แАแ‰ต แ‹ˆแ‹ญแˆ แˆ€แˆฐแ‰ต แŠฅแŠ•แ‹ฐแˆ†แА evaluate แ‹จแˆšแ‹ซแˆจแŒ expression แАแ‹แข

- Code block: แ‹ญแˆ„ แ‹ฐแŒแˆž specified แ‹จแˆ†แАแ‹ condition True แ‰ แˆ†แА แ‰แŒฅแˆญ execute แ‹จแˆšแ‹ฐแˆจแŒ แ‹จstatements แˆตแ‰ฅแˆตแ‰ฅ แАแ‹แข

Flowchart of a While Loop

1. Evaluate the condition.
2. If the condition is true, execute the code block.
3. Re-evaluate the condition.
4. If the condition is still true, repeat the code block.
5. Continue until the condition becomes false.


to be cont'd...

#WhileLoop

@python_pioneers
@python_pioneers
โšก1
...cont'd

แˆแˆณแˆŒ:
แ‰ แ‹šแˆ… แˆแˆณแˆŒ แ‹จแˆแŠ“แ‹จแ‹ program แŠจ 1 แŠฅแˆตแŠจ 5 แ‹ซแˆ‰ แ‰แŒฅแˆฎแ‰ฝแŠ• print แ‹จแˆšแ‹ซแˆจแŒ แАแ‹:

i = 1
while i <= 5:
print(i)
i += 1 # Increment the value of i by 1

Detailed Explanation

1. Initialization: i is initialized to 1 แˆ›แˆˆแ‰ตแˆ i แ‹จแˆšแ‰ฃแˆ variable initial valueแ‹แŠ• แŠ แŠ•แ‹ต แŠ แˆญแŒˆแŠ“แˆแข

2. Condition Check: i <= 5 check แ‹ญแ‹ฐแˆจแŒ‹แˆ: conditionแŠก แŠฅแ‹แАแ‰ต แŠจแˆ†แА loopแŠก แ‹ญแ‰€แŒฅแˆ‹แˆ otherwise loopแŠก terminate แ‹ซแˆจแŒ‹แˆแข

3. Body of Loop: print(i) แ‹จ variable 'i' แŠ• current value print แ‹ซแˆจแŒ‹แˆแข

4. Increment: i is incremented by 1 using i += 1.
Increment แˆ›แˆˆแ‰ต แ‹จแŠ แŠ•แ‹ตแŠ• variable value แ‰ แˆ†แА แ‹ซแˆ…แˆ แŠ แˆ›แ‹แŠ•แ‰ต แˆ˜แŒจแˆ˜แˆญ แˆ›แˆˆแ‰ต แАแ‹แฃ แ‰ แˆ‹แ‹ญแŠ›แ‹ case each time the variable 'i' is being incremented by 1.

5. Re-evaluation: The condition i <= 5 is checked again with the new value of i.

If you have understood about while loop from the above two posts, answer these questions given below.

#WhileLoop

@python_pioneers
@python_pioneers
โค1๐Ÿ‘1
5. How is the condition in a while loop written in Python?
Anonymous Quiz
20%
A. if condition:
68%
B. while condition:
4%
C. until condition:
8%
D. for condition in range:
Comment your answers from now on...

6. What is the output of the following code?

i = 0
while i < 3:
print(i)
i += 1

A) 0 1 2

B) 0 1 2 3

C) 1 2 3

D) 0 1
7. How many times will "Hello, World!" be printed?

count = 5
while count > 0:
print("Hello, World!")
count -= 1

A) 6

B) 5

C) 4

D) Infinite
8. What will be the value of sum after the execution of the following code?

sum = 0
i = 1
while i <= 5:
sum += i
i += 1

A) 10

B) 15

C) 20

D) 5
9. What is the purpose of the following while loop?

n = 10
while n > 0:
n -= 1

A) To count up from 1 to 10

B) To count down from 10 to 1

C) To count down from 10 to 0

D) To count up from 0 to 10
10. What will be the output of the following code?

x = 0
while x < 4:
x += 1
print(x)

A) 0 1 2 3

B) 1 2 3 4

C) 0 1 2 3 4

D) 1 2 3
๐Ÿ‘1
แˆแˆ‹แ‰ฝแˆแŠ•แˆ แˆตแˆˆแ‰ฐแˆณแ‰ตแแ‰ฝแˆ แ‰ แŒฃแˆ แŠฅแŠ“แˆ˜แˆฐแŒแŠ“แˆˆแŠ•!

แ‰ แ‰ดแŠญแŠ–แˆŽแŒ‚แ‹ แ‹˜แˆญแ แ‰ฅแ‰ แ‹จแˆ†แА แ‰ตแ‹แˆแ‹ต แˆ›แแˆซแ‰ต แАแŒŒ แˆ‹แ‹ญ แŠ แ‹ตแŒ‹ แˆแŠ“แ‹ซแ‰ต แ‹จแˆแŠ•แˆแˆแŒ‹แ‰ตแŠ• แŠขแ‰ตแ‹ฎแŒตแ‹ซ แˆˆแˆ˜แŒˆแŠ•แ‰ฃแ‰ต แ‹‹แАแŠ› แŠ แˆ›แˆซแŒญ แАแ‹แข

แˆ˜แˆแŠซแˆ แˆแˆฝแ‰ต!

@python_pioneers
@python_pioneers
โค2๐Ÿ‘1๐Ÿ™1
https://t.me/tapswap_mirror_1_bot?start=r_6163528558 ๐ŸŽ +2.5k Shares as a first-time gift
๐Ÿ‘2
Infinite Loop

While loopแŠ• แˆตแŠ•แŒ แ‰€แˆ common แ‹จแˆ†แА แ‰ฝแŒแˆญ แ‰ขแŠ–แˆญ แ‹จinfinite loop แˆ˜แˆแŒ แˆญ แАแ‹แข แ‹ญแˆ…แˆ infinite loop conditionแŠก False แˆ˜แ‰ผแˆ แ‰ แˆ›แ‹ญแˆ†แŠ•แ‰ แ‰ต แŒŠแ‹œ แ‹ญแˆแŒ แˆซแˆแข


Example of an infinite loop:

while True:
print("This will print forever")

แŠจแˆ‹แ‹ญ แ‹ซแˆˆแ‹ แ•แˆฎแŒแˆซแˆ "This will print forever" แ‹จแˆšแˆˆแ‹แŠ• แ‹/แАแŒˆแˆญ แ‹ซแˆˆ แŒˆแ‹ฐแ‰ฅ print แ‹ซแˆจแŒ‹แˆแข


Breaking Out of a Loop

Infinite Loop avoid แˆˆแˆ›แˆจแŒ "break" statement แˆ˜แŒ แ‰€แˆ แŠฅแŠ•แ‰ฝแˆ‹แˆˆแŠ•แฃ แ‹ญแˆ…แˆ แ‹จแˆ†แА condition set แŠ แˆญแŒˆแŠ• แŠฅแ‹แАแ‰ต แ‰ แˆšแˆ†แŠ•แ‰ แ‰ต แŒŠแ‹œ loopแŠกแŠ• exit แŠฅแŠ•แ‹ตแŠ“แˆจแŒ แ‹ญแˆจแ‹ณแŠ“แˆแข



i = 1
while i <= 10:
print(i)
if i == 5:
break # Exit the loop when i is 5
i += 1

แŠจแˆ‹แ‹ญ แ‹ซแˆˆแ‹ แ•แˆฎแŒแˆซแˆ แˆ˜แŒ€แˆ˜แˆชแ‹ซ แ‹จแ‰ฐแƒแˆแ‹ แŠจ 1 แŠฅแˆตแŠจ 10 แ‹ซแˆ‰ แ‰แŒฅแˆฎแ‰ฝแŠ• print แŠฅแŠ•แ‹ฒแ‹ซแˆจแŒ แ‰ขแˆ†แŠ•แˆ แ‹จ'i' value 5 แˆฒแˆ†แŠ• แŠฅแŠ•แ‹ฒแ‹ซแ‰†แˆ แ‰…แ‹ตแˆ˜-แˆแŠ”แ‰ณ แˆตแˆ‹แˆตแ‰€แˆ˜แŒฅแŠ• แˆแŠญ แ‹จ'i' value 5 แˆฒแˆ†แŠ• loopแŠก แ‹ญแ‰†แˆ›แˆแข


Using Else with While Loop

Python 'else' clause แŠจ while loop แŒ‹แˆญ แŠฅแŠ•แ‹ตแŠ•แŒ แ‰€แˆ แ‹ญแˆแ‰…แ‹ณแˆแข แ‹จ'else' block executed แ‹จแˆšแˆ†แАแ‹ แ‹จ while loop condition แˆ€แˆฐแ‰ต แˆฒแˆ†แŠ• แАแ‹แข (i.e., the loop terminates naturally).

แˆแˆณแˆŒ

i = 1
while i <= 5:
print(i)
i += 1
else:
print("Loop has ended")

...แ‹ญแ‰€แŒฅแˆ‹แˆ

#WhileLoop

@python_pioneers
@python_pioneers
๐Ÿ‘4โค1
๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚

-> @lewtayew

#Fun

@python_pioneers
๐Ÿ˜4๐Ÿ‘1
Common Use Cases

1. Waiting for User Input: แ‹จแˆแˆˆแŒแАแ‹แŠ• data แŠฅแˆตแŠจแˆแŠ“แŒˆแŠ User input แ‰ แ‰ฐแ‹ฐแŒ‹แŒ‹แˆš แŠฅแŠ•แ‹ตแŠ•แ‰€แ‰ แˆ แ‹ญแˆจแ‹ณแŠ“แˆแข


2. Processing Data Streams: แˆ˜แŒจแˆจแˆป แˆ‹แ‹ญ แŠฅแˆตแŠจแˆแŠ•แ‹ฐแˆญแˆต data แŠจfile แ‹ˆแ‹ญแˆ แŠจ network stream continuously แŠฅแŠ•แ‹ตแŠ“แАแ‰ฅ แ‹ญแˆจแ‹ณแŠ“แˆแข

3. Polling: แ‹จแŠ แŠ•แ‹ตแŠ• resource status periodically check แŠฅแŠ•แ‹ตแŠ“แˆจแŒ แ‹ญแˆจแ‹ณแŠ“แˆแข

แˆแˆณแˆŒ: User Input

Here's an example where we keep asking the user for a positive number:

number = -1
while number < 0:
number = int(input("Enter a positive number: "))
print("You entered: ", number)

แŠจแˆ‹แ‹ญ แ‹ซแˆˆแ‹ แ•แˆฎแŒแˆซแˆ userแŠก positive แ‰แŒฅแˆญ แŠฅแŠ•แ‹ฒแ‹ซแˆตแŒˆแ‰ฃ repeatedly แ‹ญแŒ แ‹ญแ‰€แ‹‹แˆแฃ แ‰แŒฅแˆฉแŠ• แ‹ฐแŒแˆž print แ‹ซแˆจแŒ‹แˆแฃ if the user enters a positive number the loop ends, because the condition becomes false.

...to be continued

#WhileLoop

@python_pioneers
@python_pioneers
๐Ÿ‘2