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
Test your knowledge about basics of lists in python with these๐ questions
1. Which of the following statements is true about Python lists?
Anonymous Quiz
6%
A) Lists are immutable.
84%
B) Lists can contain elements of different data types.
9%
C) Lists must contain only elements of the same data type.
0%
D) Lists do not support slicing.
2. How do you create an empty list in Python?
Anonymous Quiz
22%
A) my_list = ()
10%
B) my_list = {}
68%
C) my_list = []
0%
D) my_list = None
3. How do you create a list in Python?
Anonymous Quiz
11%
A) my_list = {1, 2, 3}
78%
B) my_list = [1, 2, 3]
11%
C) my_list = (1, 2, 3)
0%
D) my_list = "1, 2, 3"
4. Why are lists commonly used in Python?
Anonymous Quiz
3%
A) They can only store numbers
86%
B) They allow storing a sequence of items in a single variable
6%
C) They are faster than other data structures
6%
D) They can only store text data
5. Why are lists preferred for storing a collection of data items in Python?
Anonymous Quiz
9%
A) Lists automatically sort the items
6%
B) Lists are read-only and cannot be changed
73%
C) Lists allow easy addition, removal, and access of items
12%
D) Lists consume less memory compared to other data structures