๐3
Hey everyone!
แแฃแญ แตแแ แญแณแฝแ แจแแแแ แตแ for loop แแแข
Stay tuned for some exciting exercises and examples in our upcoming session!
#ForLoop
@python_pioneers
แแฃแญ แตแแ แญแณแฝแ แจแแแแ แตแ for loop แแแข
Stay tuned for some exciting exercises and examples in our upcoming session!
#ForLoop
@python_pioneers
๐4
Forwarded from Python Pioneers: A Beginner's Guide ๐ช๐น (Zaphnath Paaneah) via @OfficialBannersBot
Explore the Lessons We've Been Learning: Click the Links Below to Dive into Various Topics
FOR LOOP
For loopแ แ Python แจแแแ แแแ แจแแแ line of code แแญแ แฅแแฐ list, tuple, string, range, numbers... แจแแณแฐแ sequence of elements แ แฐแฐแแแ execute แแแจแ แแแข แญแ แฐแแ แ sequenceแก แฅแซแแณแแฑ item แแญ แฐแแณแณแญ operation แฅแแตแแซแแต แญแจแณแแแข
แ Python แจfor loop basic syntax แญแแ แญแแตแแ:
แ syntaxแก แแตแฅ:
- "item" แจแแแ แ แฅแซแแณแแฑ Iteration(แตแแแแฝ) แจsequenceแกแ every item แญแแญแแ(placeholder variable แแแข)
- "sequence" แจแแแ แฐแแ แจแแแญแแ loopแก iterate แจแแซแจแแฃแธแ elements of sequenceแ แแแข
แฅแตแช แจแแญ แซแแแ แแณแฅ แ แแณแ แฅแแจแแฃ แ แแณแแ แฐแแ แจแแ แจแแฅแฎแฝ แตแฅแตแฅ แ แ แฃ แจแแ แ listแก iterate แฅแซแจแ แฅแซแแณแแฑแ แแฅแญ print แจแแซแฐแญแ program แแแแ แฅแแแญแซแแแข
We will learn deeply about lists in the future...
This would output:
...to be continued
#ForLoop
@python_pioneers
@python_pioneers
For loopแ แ Python แจแแแ แแแ แจแแแ line of code แแญแ แฅแแฐ list, tuple, string, range, numbers... แจแแณแฐแ sequence of elements แ แฐแฐแแแ execute แแแจแ แแแข แญแ แฐแแ แ sequenceแก แฅแซแแณแแฑ item แแญ แฐแแณแณแญ operation แฅแแตแแซแแต แญแจแณแแแข
แ Python แจfor loop basic syntax แญแแ แญแแตแแ:
for item in sequence:
# do something with item
แ syntaxแก แแตแฅ:
- "item" แจแแแ แ แฅแซแแณแแฑ Iteration(แตแแแแฝ) แจsequenceแกแ every item แญแแญแแ(placeholder variable แแแข)
- "sequence" แจแแแ แฐแแ แจแแแญแแ loopแก iterate แจแแซแจแแฃแธแ elements of sequenceแ แแแข
แฅแตแช แจแแญ แซแแแ แแณแฅ แ แแณแ แฅแแจแแฃ แ แแณแแ แฐแแ แจแแ แจแแฅแฎแฝ แตแฅแตแฅ แ แ แฃ แจแแ แ listแก iterate แฅแซแจแ แฅแซแแณแแฑแ แแฅแญ print แจแแซแฐแญแ program แแแแ แฅแแแญแซแแแข
We will learn deeply about lists in the future...
numbers = [1, 2, 3, 4, 5]
for num in numbers:
print(num)
This would output:
1
2
3
4
5
...to be continued
#ForLoop
@python_pioneers
@python_pioneers
๐4๐ฅฐ1
... continued
For loopแ แจrange() functionแ แแญ แแ แแ แฅแแฝแแแแฃ แ แแ แฐแแ แจแแ range of numbers แแญ iterate แฅแแจแแแแข
แจ
แจ
- start
This would output:
...to be continued
@python_pioneers
@python_pioneers
@python_pioneers
For loopแ แจrange() functionแ แแญ แแ แแ แฅแแฝแแแแฃ แ แแ แฐแแ แจแแ range of numbers แแญ iterate แฅแแจแแแแข
แจ
range() function Python built-in function แฒแแ sequence of numbers แฅแแตแแแฅแญ แญแจแณแแแข แฅแแ แจfor loop แแญ แฐแ แ
แแ over the sequence of numbers iterate แแตแจแ แฅแแฝแแแแขแจ
range() function syntax แญแแ แญแแตแแแกrange(start, stop, step)
- start
is the starting number of the sequence (optional, default is 0)
- stop is the ending number of the sequence (required)
- step is the difference between each number in the sequence (optional, default is 1)
แแณแ 1: แ range function แจ0-9 แแฅแฎแฝแ แแแแฃแต แจแแแแแก range(9) แแแต แฅแแฝแแแแข
แแณแ 2:
for kutir in range(1, 6):
print(kutir)
This would output:
1
2
3
4
5
...to be continued
@python_pioneers
@python_pioneers
@python_pioneers
๐6๐ฅ1
"You can't go back and change the beginning, but you can start where you are and change the ending."
-C.S. Lewis
แธแธแต แแตแฅ แแแฃแณแฝแ แฅแ แ แแ แแฐ แแ แแฐแ แแแฐแญแแธแ แจแแแฝแแธแแ แแแฎแฝ แซแแแแจแฅ แแฐแฅ แแแ แแแข แแแญ แแ แซแแแ แแแญ แแญ แแแจแณแฝแ แแแ แ แญแ แ แแแแข แแฐ แแ แฐแแแฐแ แจแแแแ(แจแฐแซแแธแแ แตแ แฐแถแฝ) แแแแฅ แ แแฝแแ แแแญ แแ แ แแ แแแจแ แฅแแณแจแ แแแฅ แแแฃแต แฅแแฝแแแแข
แแแซแ แแฝแต!
#Quotes
@python_pioneers
@python_pioneers
-C.S. Lewis
แธแธแต แแตแฅ แแแฃแณแฝแ แฅแ แ แแ แแฐ แแ แแฐแ แแแฐแญแแธแ แจแแแฝแแธแแ แแแฎแฝ แซแแแแจแฅ แแฐแฅ แแแ แแแข แแแญ แแ แซแแแ แแแญ แแญ แแแจแณแฝแ แแแ แ แญแ แ แแแแข แแฐ แแ แฐแแแฐแ แจแแแแ(แจแฐแซแแธแแ แตแ แฐแถแฝ) แแแแฅ แ แแฝแแ แแแญ แแ แ แแ แแแจแ แฅแแณแจแ แแแฅ แแแฃแต แฅแแฝแแแแข
แแแซแ แแฝแต!
#Quotes
@python_pioneers
@python_pioneers
๐ฅ4โค3๐ฏ1
Forwarded from ๐๐๐๐ ๐๐๐
https://t.me/tapswap_mirror_bot?start=r_5685218492
๐ +2.5k Shares as a first-time gift
๐ +2.5k Shares as a first-time gift
๐1๐ฅฐ1
PYTHON PIONEERS
Begin your coding journey with us! Join our Telegram and YouTube channels and start learning programming in Amharic today.
Start now and unlock endless possibilities with us.
Let's code together!
@python_pioneers
@python_pioneers
Begin your coding journey with us! Join our Telegram and YouTube channels and start learning programming in Amharic today.
Start now and unlock endless possibilities with us.
Let's code together!
@python_pioneers
@python_pioneers
๐4โค1๐ฅ1
Python Range Function
Practice Problems
โญ๏ธ
range()
Practice Problems
โญ๏ธ
1. What does the following code snippet do in Python?
for i in range(5): print(i)
for i in range(5): print(i)
Anonymous Quiz
57%
a) Prints numbers from 0 to 4
5%
b) Prints numbers from 1 to 5
23%
c) Prints numbers from 0 to 5
15%
d) Prints numbers from 1 to 4
2. What is the correct syntax for using the range function with a start, end, and step value specified?
Anonymous Quiz
46%
a) range(start, end, step)
19%
b) range(start:end:step)
32%
c) range(start, step, end)
3%
d) range(end, start, step)
3. What is the output of the following code snippet:
for i in range(2, 8, 2): print(i)
for i in range(2, 8, 2): print(i)
Anonymous Quiz
25%
a) 2, 3, 4, 5, 6, 7
69%
b) 2, 4, 6
6%
c) 3, 5, 7
0%
d) 2, 5
๐1
4. In Python, what is the default step value for the range function if not specified?
Anonymous Quiz
61%
a) 1
6%
b) 2
24%
c) 0
9%
d) The step value must always be specified