Forwarded from Code Tactics (๐๐พ๐๐๐๐๐๐ฏ๐๐)
Please open Telegram to view this post
VIEW IN TELEGRAM
แฐแแ แฅแแฐแแ แแซแฝแ แจแปแแแฝแแข แจ @python_pioneers Subscribers!
แณแแแแ แฅแ แแญแฐแแแฃ แแ แ แแ แญแจแแต แตแแ แญแณแฝแแ แฅแแแฅแแแแฃ แแแแแ แ แญแแต แฅแซแ แแญแ แญแแ แฅแณแจแแฃ แฅแตแจแแฉ แฅแแฝแ แจแแณแตแกแตแ suggestion แจแแตแ แต แแฐแแ แ แตแ แแข
แ แแ แญแจแแต แฅแแ แปแแ แแญ แจแแแ แฎแแฐแแถแฝ:
โซ๏ธContd lessons on Python
โซ๏ธAward-winning questions and quizzes
โซ๏ธTech related news
โซ๏ธLive sessions
โซ๏ธDaily inspiring quotes
โซ๏ธTech related stuffs
โซ๏ธ...
แ แแ แญแจแแต แแฎแแซแแแ แจแแแญ แแณแฅ แซแแฝแ แญแ แปแแ แ แชแ แแแฃ แจแฅแ แแญ แ แแแญ แญแจแแณแฝแแ แแฌแซแ แฅแแฐแแณแฐแญแแ แฅแญแแ แแฝ แแแข
@python_pioneers
@python_pioneers
แณแแแแ แฅแ แแญแฐแแแฃ แแ แ แแ แญแจแแต แตแแ แญแณแฝแแ แฅแแแฅแแแแฃ แแแแแ แ แญแแต แฅแซแ แแญแ แญแแ แฅแณแจแแฃ แฅแตแจแแฉ แฅแแฝแ แจแแณแตแกแตแ suggestion แจแแตแ แต แแฐแแ แ แตแ แแข
แ แแ แญแจแแต แฅแแ แปแแ แแญ แจแแแ แฎแแฐแแถแฝ:
โซ๏ธContd lessons on Python
โซ๏ธAward-winning questions and quizzes
โซ๏ธTech related news
โซ๏ธLive sessions
โซ๏ธDaily inspiring quotes
โซ๏ธTech related stuffs
โซ๏ธ...
แ แแ แญแจแแต แแฎแแซแแแ แจแแแญ แแณแฅ แซแแฝแ แญแ แปแแ แ แชแ แแแฃ แจแฅแ แแญ แ แแแญ แญแจแแณแฝแแ แแฌแซแ แฅแแฐแแณแฐแญแแ แฅแญแแ แแฝ แแแข
แแแซแ แแ แญแแแแฝแ!
@python_pioneers
@python_pioneers
๐4โค1
Control Flow Modifiers in Python
แ python Control flow modifiers แจแแแแธแ แ loop แแญแ แ conditional statements แแตแฅ แจแแก normal flow of executionแ แจแแแญแฉ statementแฆแฝ แแธแแข
แฅแแแ แ modifiers แฅแ
1. break Statement
แญแ แ แจ break statement แจแแแ แแแ แ แแตแ loop prematurely แแญแ แแจแจแป แแญ แณแญแฐแญแต แแแแ แตแแแแ แแแข แฅแแ loopแก terminate แซแจแแ แจloopแก แแฅแ แแแแชแซ แซแแ line of code executed แญแแแแข
- แแแณแ:
2. continue Statement
แญแ แแ modifier แฐแแ แจloopแก current iteration แแตแฅ แซแแแ code แแแ แแฐ แแฃแญ iteration แแแแ แตแแแแ แฅแแ แแแแแแข
loopแกแ terminate แ แซแจแแแ แฃ it just skips the remaining code for the current iteration.
- แแแณแ:
..to be contd
#break
#continue
@python_pioneers
@python_pioneers
แ python Control flow modifiers แจแแแแธแ แ loop แแญแ แ conditional statements แแตแฅ แจแแก normal flow of executionแ แจแแแญแฉ statementแฆแฝ แแธแแข
แฅแแแ แ modifiers แฅแ
break, continue, แฅแ pass แแธแ1. break Statement
แญแ แ แจ break statement แจแแแ แแแ แ แแตแ loop prematurely แแญแ แแจแจแป แแญ แณแญแฐแญแต แแแแ แตแแแแ แแแข แฅแแ loopแก terminate แซแจแแ แจloopแก แแฅแ แแแแชแซ แซแแ line of code executed แญแแแแข
- แแแณแ:
for i in range(10):
if i == 4:
break
print(i) # Output: 0, 1, 2, 3
2. continue Statement
แญแ แแ modifier แฐแแ แจloopแก current iteration แแตแฅ แซแแแ code แแแ แแฐ แแฃแญ iteration แแแแ แตแแแแ แฅแแ แแแแแแข
loopแกแ terminate แ แซแจแแแ แฃ it just skips the remaining code for the current iteration.
- แแแณแ:
for i in range(10):
if i % 2 == 0:
continue
print(i) # Output: 1, 3, 5, 7, 9
..to be contd
#break
#continue
@python_pioneers
@python_pioneers
โค3
...contd
3. pass Statement
It is a no-operation statement in Python
-
- แแแณแ:
4. else Clause with Loops
else clause แจloop แแญ แแ แแ แฅแแฝแแแแฃ as long as a break statement is not used.
- แแแณแ:
- แแณแ : elseแ after break แตแแ แแ:
แฅแแแ แ control flow modifiers แแจแณแต แจloops แฅแ conditionals flow manage แ แแจแ efficient แฅแ readable code แแแ แฅแแตแตแฝแ แญแจแณแฝแแแข
#pass
#break
@python_pioneers
@python_pioneers
3. pass Statement
It is a no-operation statement in Python
-
pass statementแ แจแแแ แแแ แฅแแฐ place holder แแแข แแแตแ แจแแ code แฅแจแแแฝแ แจแแ แแ แ แแ แจแแตแจแแฉแต line of code แซแ 'pass' แ แฅแแฐ place holder แตแ แแแณแแฝแแข- แแแณแ:
if condition:
pass # To be implemented later
4. else Clause with Loops
else clause แจloop แแญ แแ แแ แฅแแฝแแแแฃ as long as a break statement is not used.
- แแแณแ:
for i in range(5):
print(i)
else:
print("Loop completed") # This will be printed because the loop was not terminated by a break
- แแณแ : elseแ after break แตแแ แแ:
for i in range(5):
if i == 3:
break
print(i)
else:
print("Loop completed") # This will not be printed because the loop was terminated by a break
แฅแแแ แ control flow modifiers แแจแณแต แจloops แฅแ conditionals flow manage แ แแจแ efficient แฅแ readable code แแแ แฅแแตแตแฝแ แญแจแณแฝแแแข
#pass
#break
@python_pioneers
@python_pioneers
๐ฅ1
แฅแตแช แฅแแแ
แ แจflow control modifiers แจแแก แฅแซแแแฝแ แแญแฏแธแโญ๏ธ
1. Which of the following statements is true about the if statement in Python?
Anonymous Quiz
0%
A) It must always be followed by an else statement.
63%
B) It can include elif statements for multiple conditions.
5%
C) It can only evaluate a single condition.
32%
D) It requires parentheses around the condition.
2. What will be the output of the following code?
- A) 0 1 2
- B) 0 1 2 3
- C) 0 1 2 3 4
- D) None of the above
for i in range(5):
if i == 3:
break
print(i)
- A) 0 1 2
- B) 0 1 2 3
- C) 0 1 2 3 4
- D) None of the above
๐1
3. Which keyword is used to skip the rest of the code inside the loop for the current iteration only?
Anonymous Quiz
4%
A) skip
43%
B) break
43%
C) continue
9%
D) pass
4. What will be the output of the following code?
- A) 4 3 2 1 0
- B) 4 3 1 0
- C) 5 4 3 2 1
- D) 5 4 3 1 0
x = 5
while x > 0:
x -= 1
if x == 2:
continue
print(x)
- A) 4 3 2 1 0
- B) 4 3 1 0
- C) 5 4 3 2 1
- D) 5 4 3 1 0
5. Which of the following statements about the pass statement in Python is true?
Anonymous Quiz
14%
A) It terminates the loop immediately.
43%
B) It is used to skip an iteration in a loop.
38%
C) It is a null operation used as a placeholder.
5%
D) It raises an exception.
You're gonna write a python program that processes numbers from 1 to 20 and follow these rules.
1. Skip (continue) numbers that are divisible by 3.
2. Stop (break) the loop if the number is greater than 15.
Print all the other numbers
You can use for loop to iterate through the numbers 1 to 20
แฅแตแฒ แแญแฉแต
#Exercise
@python_pioneers
1. Skip (continue) numbers that are divisible by 3.
2. Stop (break) the loop if the number is greater than 15.
Print all the other numbers
แฅแตแฒ แแญแฉแต
#Exercise
@python_pioneers
๐2
Google or Googol
The name Google was created accidentally, it was originally supposed to be named โGoogolโ. (Googol is the digit 1 followed by 100 zeroes).
The founders checked to see if that domain name was taken, but accidentally searched for โgoogle.comโ instead of โgoogol.comโ.
They liked that name even better and registered the domain name on September 15, 1997
#Facts
#Google
@python_pioneers
The name Google was created accidentally, it was originally supposed to be named โGoogolโ. (Googol is the digit 1 followed by 100 zeroes).
The founders checked to see if that domain name was taken, but accidentally searched for โgoogle.comโ instead of โgoogol.comโ.
They liked that name even better and registered the domain name on September 15, 1997
#Facts
@python_pioneers
๐2
THE ONLY WAY TO AVOID MISTAKES IS TO GAIN EXPERIENCE; THE ONLY WAY TO GAIN EXPERIENCE IS BY MAKING MISTAKES.
This quote reminds us that mistakes are an integral part of the process of learning and growth.
แแแซแ แแฝแต แญแแแแฝแ!
#Quotes
-> @Gr8r_Abb
๐ฌ Buzz Quotes
@python_pioneers
โค3๐ฅ1
แ แแฃแญ =>
แ แแฃแญ แ Python List แแ แฅแแฐแแแฃ แแแ แฅแแฐแแซแตแแแแแ แฅแแดแต แแ แแ แฅแแณแแฅแ แฅแแแซแแแข
Stay tuned!
@python_pioneers
@python_pioneers
LISTS IN PYTHON
แ แแฃแญ แ Python List แแ แฅแแฐแแแฃ แแแ แฅแแฐแแซแตแแแแแ แฅแแดแต แแ แแ แฅแแณแแฅแ แฅแแแซแแแข
Stay tuned!
@python_pioneers
@python_pioneers
๐3
Forwarded from The Coffee Talk Table
แ แแ แแ แ แแณ แ แฐแ แแฐแแแแแ แแฐแแฑ แจแ
แฅแจแฐแฐแฅ แญแแแฝ แตแแ แฅแแตแญแแฃ แ แ
แญแแต แแฐแจแแต แฅแแตแจแตแแธแ
แ แแ แจแ แฐแ แแ แแแแแต แแแแแซ :
แจแขแตแฎแตแซ แแแต แฃแแญ แแณแฅ แแฅแญ
แแญ แตแแ แฅแแฒแซแฐแญแ แฐแ แญแแแแข
แฅแตแซแแ 230 แฐแแฝ แ แญแแต แ แแ แ แฐแ แ แแแ : :
แ แแ แจแ แฐแ แแ แแแแแต แแแแแซ :
แจแขแตแฎแตแซ แแแต แฃแแญ แแณแฅ แแฅแญ
1000511561276 แแญ แตแแ แฅแแฒแซแฐแญแ แฐแ แญแแแแข
แฅแตแซแแ 230 แฐแแฝ แ แญแแต แ แแ แ แฐแ แ แแแ : :
๐ข2
Introduction to Lists
แ แแต แแฎแแซแ แ แแแฝแแ แต แแ แฅแ แแจแแแฝแ store แฅแแจแแแ แจแแซแ แฅแแแซ แแจแแแฝ manage แแแตแจแ แจแแซแตแธแแฉ แญแแแแข แฅแแฑแ แฐแแ retrieve แแจแ แฃ แแแฃแตแฃ แแแแต แฅแ แแ แแ แ แฃแ แจแฃแต แญแแแแข
แตแแแ แฅแแแซแ แแจแแแฝ แ แกแตแ/แ แแแฐแฅ/ แจแแซแ แ แ แแต variable แแตแฅ store แแจแ แ แแฅแแข แ Programming แแตแฅ, แญแ แแฐแต แฅแแฐ Data structure แญแฃแแแข
Data Structure is a particular way of organizing data in a computer so that it can be used effectively.
แจ List แฃแ แชแซแต
1. Lists แฐแแณแณแญ แแญแ แจแฐแแซแจ (heterogeneous) data types store แแตแจแ แญแฝแแ
2. Lists dynamic แแธแ แแแตแ we don't need to mention the size of the list while declaring.
3. Order is preserved, แแญแ insert แซแจแแแแ data as long as there are no modifications to the list แ แฐแแณแณแญ order แแ outputแกแแ แจแแแแแแข
4. Lists duplicate แจแแ element แแซแ แญแฝแแ
5. In lists แแแแ แแ แจแแซแแฐแ index แแแฃ Index แ แแ แแ แแ แจlistแกแ elements access แจแแแจแแ (
6. List objects mutable แแธแ แแแตแ listแก แจแฐแแ แจ แ แแ แจlistแกแ content modify แแจแ แแญแ แแแจแญ แฅแแฝแแแแข
...to be contd
#Lists
@python_pioneers
@python_pioneers
๐2
...contd
List create แแแจแ แฅแ แ แญแแต แแแแถแฝ แ แแฃ แฅแตแช แ แแณแ แฅแแแแจแณแธแ:
1. Using square brackets
แ python list square brackets แ แแ แแ แแแ แญ แฅแแฝแแแแฃ แจlistแกแ elements แฐแแ แ comma แฅแแแซแซแธแแแแข
Syntax
:
list_name = [elements]
แแแณแ:
2. Using list() function
แแแฐแแ list แแแ แชแซ แแแแต แฐแแ list() แจแแฃแ built-in function แ แแ แแ แแแข แญแแ แฐแแ แจแแแ แแแ แจแฐแแซแฉ data types like : strings, set, tuple ...etc list แแแ แญ แตแแแแ แแแข
Set, tuple, Dictionary -> แ แแฃแญ แฅแแแซแธแแแ
แแแณแ:
3. Using list() and range() function
แจrange() function sequence of numbers create แซแจแแแฃ starting from 0 by default, and increments by 1 (by default), แฅแ specified แจแแแ แแฅแญ แ แแต แญแแแแข
...to be contd
#Lists
@python_pioneers
@python_pioneers
How to create a List?
List create แแแจแ แฅแ แ แญแแต แแแแถแฝ แ แแฃ แฅแตแช แ แแณแ แฅแแแแจแณแธแ:
1. Using square brackets
แ python list square brackets แ แแ แแ แแแ แญ แฅแแฝแแแแฃ แจlistแกแ elements แฐแแ แ comma แฅแแแซแซแธแแแแข
Syntax
:
list_name = [elements]
แแแณแ:
my_list = [1, 2, 3, 4, 5]
2. Using list() function
แแแฐแแ list แแแ แชแซ แแแแต แฐแแ list() แจแแฃแ built-in function แ แแ แแ แแแข แญแแ แฐแแ แจแแแ แแแ แจแฐแแซแฉ data types like : strings, set, tuple ...etc list แแแ แญ แตแแแแ แแแข
แแแณแ:
name = "ABEBE"
my_list = list(name)
print(my_list) # Output : ['A', 'B', 'E', 'B', 'E']
3. Using list() and range() function
แจrange() function sequence of numbers create แซแจแแแฃ starting from 0 by default, and increments by 1 (by default), แฅแ specified แจแแแ แแฅแญ แ แแต แญแแแแข
...to be contd
#Lists
@python_pioneers
@python_pioneers
๐5๐1