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
Insertion of List Elements

โžก๏ธ
INSERTION OF LIST ELEMENTS

แŠ แŠ•แ‹ต list แ‹แˆตแŒฅ แŠ แ‹ณแˆต element แ‹จแˆแŠ•แŒจแˆแˆญแ‰ แ‰ต แ‰ฅแ‹™ แŠ แ‹ญแАแ‰ต แˆ˜แŠ•แŒˆแ‹ต แŠ แˆˆแฃ แŠจแŠฅแАแ‹›แˆ แˆ˜แŠ•แŒˆแ‹ถแ‰ฝ แˆแˆˆแ‰ฑแŠ• แŠฅแŠ•แ‹ญแข

1. append() method

แ‹ญแˆ„แŠ•แŠ• method แ‰ แŒ แ‰€แˆ แŠ แŠ•แ‹ต list แ‹แˆตแŒฅ แŠ แ‹ฒแˆต element แˆ˜แŒจแˆ˜แˆญ แŠฅแŠ•แ‰ฝแˆ‹แˆˆแŠ•แฃ add แ‹จแˆแŠ“แˆจแŒˆแ‹ element แ‹ฐแŒแˆž แ‹จแˆšแŒจแˆ˜แˆจแ‹ แ‹จlistแŠก แˆ˜แŒจแˆจแˆป แˆ‹แ‹ญ แАแ‹แข

Syntax :
list_name.append(new_element)

แˆˆแˆแˆณแˆŒ:

countrys = ["Ethiopia", "Uganda", "France"]
#if I want to add "Kenya" in the list I can use append() and it will add the country's name at the end of the list
countrys.append("Kenya")
print(countrys)

#Output : ["Ethiopia", "Uganda", "France", "Kenya"]

2. insert() method

แ‹ญแˆ„แŠ›แ‹แŠ• method แ‹ฐแŒแˆž แŠ แ‹ฒแˆต element specified แ‹จแˆ†แА แ‰ฆแ‰ณ แˆ‹แ‹ญ แˆˆแˆ›แˆตแŒˆแ‰ฃแ‰ต แˆตแŠ•แˆแˆแŒ แŠฅแŠ•แŒ แ‰€แˆ˜แ‹‹แˆˆแŠ•แข แˆแˆˆแ‰ต argument แŠฅแŠ•แ‹ฐ input แ‹ญแ‹ˆแˆตแ‹ณแˆ one is the index and the other is the element.

An argument refers to the value that is passed to a function or method when it is called.

Syntax :
list_name.insert(i, new_element)

แˆˆแˆแˆณแˆŒ:

countrys = ["Ethiopia", "Uganda", "France"]
#I can use the insert method here to add the country name at specified index

countrys.insert(2, "Kenya")
print(countrys)

#Output : ["Ethiopia", "Uganda", "Kenya", "France"]

...

#Lists
#Python

@python_pioneers
@python_pioneers
Forwarded from Zaphnath Paaneah
Join our channel and embark on your coding journey with us!

๐Ÿ‘‰ @python_pioneers

Gain access to free coding lessons in Amharic language. Additionally, stay updated on the latest tech news and new innovations.

PythonแŠ• แ‰ แŠ แˆ›แˆญแŠ› แŠฅแŠ•แˆ›แˆญ!

@python_pioneers
@python_pioneers
๐Ÿ‘2โค1โšก1
Arranging a List

แ‹จแŠ แŠ•แ‹ตแŠ• list elements order แ‰ แˆแŠ•แˆแˆแŒˆแ‹ แˆ˜แŠ•แŒˆแ‹ต แˆ›แ‹ตแˆจแŒ แŠฅแŠ•แ‰ฝแˆ‹แˆˆแŠ•แฃ แ‹ญแˆ„แŠ•แŠ•แˆ แ‹จแˆแŠ“แˆจแŒˆแ‹ แ‰ แŠฅแАแ‹šแˆ… methods แАแ‹แข

1. sort() method

In a list by default insertion order is preserved แˆ›แˆˆแ‰ตแˆ แˆ˜แŒ€แˆ˜แˆชแ‹ซ แˆ‹แ‹ญ แ‹จlistแŠกแŠ• element แ‰ฃแˆตแ‰€แˆ˜แŒฅแŠ•แ‰ แ‰ต แ‰ฆแ‰ณ แАแ‹ แ‹จแˆแŠ“แŒˆแŠ˜แ‹แข

If we want to sort the elements of the list according to default natural sorting order then we should go for sort() method.

แˆˆ แ‰แŒฅแˆฎแ‰ฝ default natural sorting order ascending order แАแ‹แข
แˆˆ strings default natural sorting order alphabetical order แАแ‹แข

sort() method แˆˆแˆ˜แŒ แ‰€แˆ listแŠก แ‰ฐแˆ˜แˆณแˆณแ‹ญ type แ‹ซแˆ‹แ‰ธแ‹แŠ• elements แˆ˜แ‹ซแ‹ แŠ แˆˆแ‰ แ‰ตแฃ แŠ แˆˆแ‰ แˆˆแ‹แ‹ซ we will get TypeError.

Syntax : 
list_name.sort()

แˆˆแˆแˆณแˆŒ :

yene_list = [4, 5, 3, 1, 2]
yene_list.sort()
print(yene_list)

Output : [1, 2, 3, 4, 5]

2. reverse() method

This method reverses the order of list elements.

Syntax :
list_name.reverse()

แˆˆแˆแˆณแˆŒ :

lela_list = [1, 4, 2, 8, 6]
lela_list.reverse()
print(lela_list)

Output : [8, 6, 4, 2, 1]

...

#Lists
#ArrangingLists

@python_pioneers
@python_pioneers
๐Ÿ‘1
Some programming memes

Have fun๐Ÿ˜Š

@python_pioneers
๐Ÿ˜5
๐Ÿš‘ Scientists from USA have developed an inexpensive electric bandage that speeds up wound healing by 30%.

To activate the bandage, you just need to moisten it, and it starts delivering a weak current that stimulates cells and suppresses bacterial growth.

It's a single-use product, but itโ€™s expected to cost just $1. However, thereโ€™s no production timeline yet as clinical trials are still ahead.


#Technology
#Tech
#News

@hitechdailynews
@python_pioneers
๐Ÿ‘2๐Ÿ˜จ1
๐Ÿ‘3
Nextโžก : Mathematical Operations on List (using List Methods)
Mathematical Operations on List (using List Methods)

แŠ แŠ•แ‹ต list แˆ‹แ‹ญ mathematical operations แˆˆแˆ›แŠซแˆ„แ‹ต แ‹จแˆแŠ•แŒ แ‰€แˆ›แ‰ธแ‹ แ‰ฅแ‹™ แŠ แ‹ญแАแ‰ต methods แŠฅแŠ•แ‹ตแˆแˆ แ‰ฅแ‹™ แŠฅแ‹ญแАแ‰ต functions แŠ แˆ‰แข

Let's see them one by one...

1. len()

แ‹ญแˆ„แŠ•แŠ• len() function แ‹จแˆแŠ•แŒ แ‰€แˆ˜แ‹ แ‰ แŠ แŠ•แ‹ต listแ‹แˆตแŒฅ แ‹ซแˆ‰แ‰ตแŠ• elements แ‰ฅแ‹›แ‰ต(แ‹จlistแŠกแŠ• length) แˆˆแˆ›แ‹ˆแ‰… แˆตแŠ•แˆแˆแŒ แАแ‹แข

Syntax: 
len(list_name)

แˆˆแˆแˆณแˆŒ :

Items = ["rubber", "pencil", "book", "pen"]
length = len(Items)

print(length)

#Output : 4

2. count() method

แ‹ญแˆ„แŠ•แŠ• method แ‹ฐแŒแˆž แ‹จแˆแŠ•แŒ แ‰€แˆ˜แ‹ แ‰ แŠ แŠ•แ‹ต list แ‹แˆตแŒฅ แ‹ซแˆˆ แ‹จแˆ†แА specific element แˆแŠ• แ‹ซแˆ…แˆ occur แŠฅแŠ•แ‹ณแˆจแŒˆ แˆˆแˆ›แ‹ˆแ‰… แˆตแŠ•แˆแˆแŒ แАแ‹แข

Syntax :
list_name.count(element)

แˆˆแˆแˆณแˆŒ :

alps = ["a", "e", "g", "a", "f", "g", "a"]

occurrence_of_a = alps.count("a")

print(occurrence_of_a)

#Output : 3


3. max()

max() function แ‰ แŠ แŠ•แ‹ต list แ‹แˆตแŒฅ แ‰ตแˆแ‰แŠ• element return แ‹ซแˆจแŒ‹แˆแข

Syntax :
max(list_name)

4. min()

min() function แ‹ฐแŒแˆž แ‰ แ‰ฐแ‰ƒแˆซแŠ’แ‹ แ‹จแŠ แŠ•แ‹ตแŠ• list แ‰ตแŠ•แˆนแŠ• element return แ‹ซแˆจแŒแˆแŠ“แˆแฃ

Syntax :
min(list_name)

max() แŠฅแŠ“ min() function แ‰ แˆแˆณแˆŒ แŠฅแŠ•แˆ˜แˆแŠจแ‰ตแข

nums = [5, 90, 34, 65, 23, 7, 10]

print(max(nums)) #Output : 90

print(min(nums)) #Output : 5

...

#MathsOpOnLists
#Lists

@python_pioneers
๐Ÿ‘1
Here are some multiple choice questions: Answer them by reacting for the correct ones as stated below ๐Ÿ‘‡

A == ๐Ÿ˜
B == ๐Ÿ˜ญ
C == ๐Ÿ˜ข
D == ๐Ÿค“