6โฃ. What will be the output of the following code?
a)
b)
c)
d)
my_list = [5, 10, 15, 20, 25, 30]
print(my_list[1:5:2])
a)
[10, 20] b)
[10, 15, 20, 25] c)
[10, 20, 30] d)
[10, 25]7โฃ. Given the list
, what does
return?
a)
b)
c)
d)
my_list = ['p', 'y', 't', 'h', 'o', 'n']
, what does
my_list[:4]
return?
a)
['o', 'n'] b)
['p', 'y', 't', 'h'] c)
['p', 'y', 't', 'h', 'o'] d)
['t', 'h', 'o', 'n']8โฃ. If
, what does
return?
a)
b)
c)
d)
my_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
, what does
my_list[2:8:2]
return?
a)
[2, 3, 4, 5, 6, 7] b)
[2, 4, 6, 8] c)
[2, 6] d)
[4, 8]9โฃ. What will be the result of the following code?
a)
b)
c)
d)
my_list = ['apple', 'banana', 'cherry', 'date']
print(my_list[::3])
a)
['apple', 'cherry'] b)
['apple', 'date'] c)
['banana', 'date'] d)
['apple', 'banana', 'cherry', 'date']๐. What will be the output of the following code?
a)
b)
c)
d)
my_list = [100, 200, 300, 400, 500]
print(my_list[1:5:3])
a)
[200, 400] b)
[200, 500] c)
[200, 300, 400, 500] d)
[100, 300]๐3๐ฅ2
Python Pioneers: A Beginner's Guide ๐ช๐น pinned ยซExercises Deepen Your Knowledge About List Indexing and Slicing Through These Questions๐ and don't forget to comment your answers ยป
How to modify specific element of a list?
แจ แ แแตแ list specific element แฅแป แแญแฐแ modify แแตแจแ แฅแแฝแแแแข
แแแณแ : my_list แ แแแ list แแตแฅ index 2 แแญ แซแแแ element('cap') แแฐ 'book' แฅแแแญแญแข
Old list : ['bag', 'pen', 'cap', 'pen']
Modified list : ['bag', 'pen', 'book', 'pen']
3. index() method
The index() method returns the position at the first occurrence of the specified item (value).
In Python, a method is a function that is associated with a class. It is defined inside the class and can be called using an instance of the class. Methods can perform operations on the data stored in the class and can also modify the state of the object.
แแแณแ : แจ แจแแ list แจ4แ index แแแแ แจแแแแ
to be cont'd...
@python_pioneers
@python_pioneers
แจ แ แแตแ list specific element แฅแป แแญแฐแ modify แแตแจแ แฅแแฝแแแแข
Syntax :
list_name[i] = new element
แแแณแ : my_list แ แแแ list แแตแฅ index 2 แแญ แซแแแ element('cap') แแฐ 'book' แฅแแแญแญแข
my_list = ['bag', 'pen', 'cap', 'pen']
my_list[2] = 'book'
print(my_list)
#Output : ['bag', 'pen', 'book', 'pen']
Old list : ['bag', 'pen', 'cap', 'pen']
Modified list : ['bag', 'pen', 'book', 'pen']
3. index() method
The index() method returns the position at the first occurrence of the specified item (value).
แแแณแ : แจ แจแแ list แจ4แ index แแแแ แจแแแแ
new_list = [1, 5, 6, 4, 7]
index_of_4 = new_list.index(4)
#Output : 3
to be cont'd...
@python_pioneers
@python_pioneers
๐คทโโ1
แจ25 แฅแญ แจแ แจแญ แฐแแต แจแแซแธแแ แฅแซแ
If you're ready show me your ๐
โ 3 : 15
@python_pioneers
If you're ready show me your ๐
โ 3 : 15
@python_pioneers
๐11
Python Pioneers: A Beginner's Guide ๐ช๐น
แจ25 แฅแญ แจแ แจแญ แฐแแต แจแแซแธแแ แฅแซแ If you're ready show me your ๐ โ 3 : 15 @python_pioneers
Please send me only your answers.
Send it to : @Mntsnt_ZP
The winner will be the person who gets the most correct answers in the shortest amount of time.
Good Luck!๐ค
@python_pioneers
Send it to : @Mntsnt_ZP
The winner will be the person who gets the most correct answers in the shortest amount of time.
Good Luck!๐ค
@python_pioneers
๐2
1. What is the output of the following code?
A) [1, 2, 3]
B) [2, 3, 4]
C) [2, 3, 4, 5]
D) [1, 2, 3, 4]
2. What is the result of running the following code?
A) [5, 4, 3, 2, 1]
B) [1, 2, 3, 4, 5]
C) [5, 4, 3, 2]
D) [4, 3, 2, 1]
3. What will be the output of the following code snippet?
A) [1, 2, 6, 4, 5]
B) [1, 2, 3, 6, 5]
C) [1, 2, 6, 3, 4]
D) [1, 2, 3, 4, 6]
4. What does the following code do?
A) Removes the element at index 2 from the list
B) Removes the last element from the list
C) Adds the element at index 2 to the list
D) Replaces the element at index 2 with a new value
5. How can you check if a specific value exists in a list in Python?
A) Using the in keyword
B) Using the exists() method
C) Using the exists keyword
D) Using the contains() method
#Quiz
#PrizeWinningQuiz
@python_pioneers
@python_pioneers
my_list = [1, 2, 3, 4, 5]
print(my_list[1:4])
A) [1, 2, 3]
B) [2, 3, 4]
C) [2, 3, 4, 5]
D) [1, 2, 3, 4]
2. What is the result of running the following code?
my_list = [1, 2, 3, 4, 5]
new_list = my_list[::-1]
print(new_list)
A) [5, 4, 3, 2, 1]
B) [1, 2, 3, 4, 5]
C) [5, 4, 3, 2]
D) [4, 3, 2, 1]
3. What will be the output of the following code snippet?
my_list = [1, 2, 3, 4, 5]
my_list[2] = 6
print(my_list)
A) [1, 2, 6, 4, 5]
B) [1, 2, 3, 6, 5]
C) [1, 2, 6, 3, 4]
D) [1, 2, 3, 4, 6]
4. What does the following code do?
my_list = [1, 2, 3, 4, 5]
del my_list[2]
A) Removes the element at index 2 from the list
B) Removes the last element from the list
C) Adds the element at index 2 to the list
D) Replaces the element at index 2 with a new value
5. How can you check if a specific value exists in a list in Python?
A) Using the in keyword
B) Using the exists() method
C) Using the exists keyword
D) Using the contains() method
#Quiz
#PrizeWinningQuiz
@python_pioneers
@python_pioneers
๐1
โTime's Up
Thank you all of you for your participation.
We will announce the winner...๐
Thank you all of you for your participation.
We will announce the winner...๐
๐1
โค1๐1
The winner has received the prize ๐
You all did great participating in the quiz. Most of you were correct, but some of you were a little late.
THANK YOU!
@python_pioneers
You all did great participating in the quiz. Most of you were correct, but some of you were a little late.
THANK YOU!
@python_pioneers
๐3
"The only way to achieve the impossible is to believe it is possible."
-Unknown
แแแซแ แแฝแต!
#Quote
@python_pioneers
๐ฅ2๐ฏ1
Forwarded from Luna's pathway๐ค (Luna)
The Black Dot Story
One day, a professor entered the classroom and asked his students to prepare for a surprise test. They all waited anxiously at their desks for the exam to begin. The professor handed out the exams with the text facing down, as usual. Once he handed them all out, he asked the students to turn over the papers. To everyoneโs surprise, there were no questions โ just a black dot in the center of the sheet of paper. The professor, seeing the expression on everyoneโs faces, told them the following: โI want you to write about what you see there.โ The students, confused, got started on the inexplicable task. At the end of the class, the professor took all the exams, and started reading each one of them out loud, in front of all the students. All of them, with no exception, defined the black dot, trying to explain its position in the center of the sheet. After all had been read, the classroom silent, the professor started to explain: โIโm not going to grade you on this, I just wanted to give you something to think about. No one wrote about the white part of the paper. Everyone focused on the black do โ and the same happens in our lives. We have a piece of paper to observe and enjoy, but we always focus on the dark spots. Our life is a gift, and we always have reasons to celebrate โ nature renewing itself daily, friends around us, the job that provides our livelihood, etc.
However, we insist on focusing only on the dark spot โ the health issues that bother us, the lack of money, the complicated relationships with others, or the disappointment with a friend. The dark spots are very small when compared to everything we have in our lives, but theyโre the ones that pollute our mind. Take your eyes away from the black dots in your life. Enjoy each one of your blessings and each moment that life gives you. Be happy and live a life such that even the undertaker will be disappointed when it is your time to go.
Happy Weekend๐ ๐
Tag the author if you guys know ๐
One day, a professor entered the classroom and asked his students to prepare for a surprise test. They all waited anxiously at their desks for the exam to begin. The professor handed out the exams with the text facing down, as usual. Once he handed them all out, he asked the students to turn over the papers. To everyoneโs surprise, there were no questions โ just a black dot in the center of the sheet of paper. The professor, seeing the expression on everyoneโs faces, told them the following: โI want you to write about what you see there.โ The students, confused, got started on the inexplicable task. At the end of the class, the professor took all the exams, and started reading each one of them out loud, in front of all the students. All of them, with no exception, defined the black dot, trying to explain its position in the center of the sheet. After all had been read, the classroom silent, the professor started to explain: โIโm not going to grade you on this, I just wanted to give you something to think about. No one wrote about the white part of the paper. Everyone focused on the black do โ and the same happens in our lives. We have a piece of paper to observe and enjoy, but we always focus on the dark spots. Our life is a gift, and we always have reasons to celebrate โ nature renewing itself daily, friends around us, the job that provides our livelihood, etc.
However, we insist on focusing only on the dark spot โ the health issues that bother us, the lack of money, the complicated relationships with others, or the disappointment with a friend. The dark spots are very small when compared to everything we have in our lives, but theyโre the ones that pollute our mind. Take your eyes away from the black dots in your life. Enjoy each one of your blessings and each moment that life gives you. Be happy and live a life such that even the undertaker will be disappointed when it is your time to go.
Happy Weekend
Tag the author if you guys know ๐
Please open Telegram to view this post
VIEW IN TELEGRAM
โค3
Forwarded from Abiy Ahmed Ali ๐ช๐น
แ แแฌแ แแฃแ แ แแ แฃแแฐแแฐ แตแแ
แญแต แฅแ แจแญแแแต แฅแตแแต แแตแฅ แแณแฐแ แจแแผแแ แแ แญแ แแฅ แฅแ
แ แ แตแแแ แแแแข
แ แจแแต แแญ แแแฝแ แฐแแชแแฝแฃ แแแฃแต แฃแแแซแแฝแฃ แซแณแธแแ แ แฅแแแต แ แแแแฃแต แ แแแญ แแตแฅแ แแ แ แแญ แ แ แฐแ แแ แแแแ แญ แแแตแแ แแ แจแ แแตแต แแแฎแ แฎแฐแญแต แแฎแแญแต แแณแ แแซแฐแญแแฝแ แฐแฐแแตแถแแฝแแแข แจแตแแ แญแต แฅแ แจแฅแแแต แแแปแฝแ แฅแ แซแแฝแแ แต แฐแจแ แแแ แญแแ แซแแฝแแ แญแแแต แแแณแฐแแ แแ แ แฒแต แแแญ แแแแ แแแตแน แแ แฐแ แจแฅแตแ แ แญ แฐแจแแถแแฝแแแข
แ แแแ แขแตแฎแตแซ แซแแฝแ แจแญแแแต แ แ แแแแแฝแฃ แ แฃแณแแแฝแฃ แฉแแจแญแฒแฒแแฝ แญแฝแแ แแฎแแญแต แฅแ แฅแแ แตแแดแแนแ แฅแแฒแฐแแ แฅแช แ แแญแฃแแแข
แแต แฃแแฐแฐแฅแแแฝ แฃ แจแขแตแฎแตแซแฝแ แฅแแซแฌ แ แฅแแแฐ แฅแตแแต แแญ แจแฐแแ แจแฐ แแแข
แแแแแแฅ: http://www.ethiocoders.et
In today's fast-paced world, continuous learning and skills development are more important than ever.
To all students on break, young professionals, and those eager for personal growth and making a positive impact locally and beyond: the 5 Million Coders initiative has been launched to help you stay ahead, regardless of your career stage or goals. Whether you're looking to enhance your current skills, learn something new, or prepare for future opportunities, this initiative is designed for you.
I also strongly encourage everyone involved in skill-building in Ethiopiaโincubators, accelerators, universities, and othersโto fully embrace this initiative. Our nation's strength lies in your growth!"
Register through: http://www.ethiocoders.et
แ แจแแต แแญ แแแฝแ แฐแแชแแฝแฃ แแแฃแต แฃแแแซแแฝแฃ แซแณแธแแ แ แฅแแแต แ แแแแฃแต แ แแแญ แแตแฅแ แแ แ แแญ แ แ แฐแ แแ แแแแ แญ แแแตแแ แแ แจแ แแตแต แแแฎแ แฎแฐแญแต แแฎแแญแต แแณแ แแซแฐแญแแฝแ แฐแฐแแตแถแแฝแแแข แจแตแแ แญแต แฅแ แจแฅแแแต แแแปแฝแ แฅแ แซแแฝแแ แต แฐแจแ แแแ แญแแ แซแแฝแแ แญแแแต แแแณแฐแแ แแ แ แฒแต แแแญ แแแแ แแแตแน แแ แฐแ แจแฅแตแ แ แญ แฐแจแแถแแฝแแแข
แ แแแ แขแตแฎแตแซ แซแแฝแ แจแญแแแต แ แ แแแแแฝแฃ แ แฃแณแแแฝแฃ แฉแแจแญแฒแฒแแฝ แญแฝแแ แแฎแแญแต แฅแ แฅแแ แตแแดแแนแ แฅแแฒแฐแแ แฅแช แ แแญแฃแแแข
แแต แฃแแฐแฐแฅแแแฝ แฃ แจแขแตแฎแตแซแฝแ แฅแแซแฌ แ แฅแแแฐ แฅแตแแต แแญ แจแฐแแ แจแฐ แแแข
แแแแแแฅ: http://www.ethiocoders.et
In today's fast-paced world, continuous learning and skills development are more important than ever.
To all students on break, young professionals, and those eager for personal growth and making a positive impact locally and beyond: the 5 Million Coders initiative has been launched to help you stay ahead, regardless of your career stage or goals. Whether you're looking to enhance your current skills, learn something new, or prepare for future opportunities, this initiative is designed for you.
I also strongly encourage everyone involved in skill-building in Ethiopiaโincubators, accelerators, universities, and othersโto fully embrace this initiative. Our nation's strength lies in your growth!"
Register through: http://www.ethiocoders.et
๐1
This media is not supported in your browser
VIEW IN TELEGRAM
Realme has announced a 300W fast charger. Thanks to the new technology, the smartphone charges from 0 to 50% in 3 minutes and up to 100% in less than 5 minutes. Details will be revealed on August 14 at the presentation of the new product
๐๐ฒ @TechnologyBoxs
@python_pioneers
๐๐ฒ @TechnologyBoxs
@python_pioneers
Insertion of List Elements
โก๏ธ