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 == 🤓
A == 😁
B == 😭
C == 😢
D == 🤓
1. What is the result of the following operation?
- 😁)
list1 = [1, 2, 3]
list2 = [4, 5, 6]
result = list1 + list2
- 😁)
[1, 2, 3, 4, 5, 6]
-😭) [5, 7, 9]
-😢) [(1, 4), (2, 5), (3, 6)]
-🤓) None of the above😁8
2. What does the following Python code return?
- 😁)
list1 = [1, 2, 3]
result = list1 * 2
- 😁)
[2, 4, 6]
-😭) [1, 2, 3, 1, 2, 3]
-😢) [1, 1, 2, 2, 3, 3]
-🤓) None of the above😭6😁1
Forwarded from Python Pioneers: A Beginner's Guide 🇪🇹
Nice question
In case of lists containing strings, when we use max() and min() function, they return the maximum or minimum element based on lexicographical order
ለምሳሌ:
"name" has higher lexicographic order than "age", so if we use max() for a list containing only the two, the function returns "name"
But also there's something called key, in which you specify the criteria you want to compare by
Is this helpful 👆
In case of lists containing strings, when we use max() and min() function, they return the maximum or minimum element based on lexicographical order
ለምሳሌ:
"name" has higher lexicographic order than "age", so if we use max() for a list containing only the two, the function returns "name"
But also there's something called key, in which you specify the criteria you want to compare by
Is this helpful 👆
👍2
3. What will be the output of the following code?
😁) 5
😭) 10
😢) 25
🤓) 20
numbers = [5, 10, 15, 20, 25]
print(max(numbers))
😁) 5
😭) 10
😢) 25
🤓) 20
😢6
4. What will be the output of the following code?
😁) 9
😭) 4
😢) 3
🤓) 5
numbers = [3, 7, 2, 9, 4]
print(len(numbers))
😁) 9
😭) 4
😢) 3
🤓) 5
🤓3
5. What will be the output of the following code?
😁) "apple"
😭) "banana"
😢) "orange"
🤓) "kiwi"
words = ["apple", "banana", "orange", "kiwi"]
print(max(words))
😁) "apple"
😭) "banana"
😢) "orange"
🤓) "kiwi"
😭1
6. What will be the output of the following code?
😁) "cat"
😭) "bird"
😢) "sheep"
🤓) "elephant"
words = ["cat", "sheep", "elephant", "bird"]
print(min(words, key=len))
😁) "cat"
😭) "bird"
😢) "sheep"
🤓) "elephant"
😁2🤓1
Shake off problems:
Moral: Don’t choose to live with your problem. Just shake off your problems and stand on it and step up in life after learning from them. Every bad experience is a new learning. So get the positives out of it and work towards your goals.
#Stories
@python_pioneers
A man and his donkey were on the way to grazing while the donkey fell into a huge pit. The man was shaken and tried hard to pull off his favorite donkey up to the ground.
Despite his strenuous attempts, he failed to bring the donkey back. But he can’t leave the donkey to starve and die with pain for days.
So he decided to bury him alive and make his death smoother. So he started pouring soil over the donkey in the pit. When he poured the soil, the donkey felt the load and shakes it off and he steps on it.
He does the same every time when the soil was poured on his body. In the end, he reached the ground level and easily walked away to graze in the green pastures.
Moral: Don’t choose to live with your problem. Just shake off your problems and stand on it and step up in life after learning from them. Every bad experience is a new learning. So get the positives out of it and work towards your goals.
#Stories
@python_pioneers
❤3🔥2
Memory of the past
This was our first post, at the time there were only 69 subscribers, but now there are so many ppl, who also become part of this family 🥰
ሁላችሁንም ስለ አብሮነታችሁ፣ የጉዟችን አካል ስለሆናችሁ እናመሰግናለን!
@python_pioneers
This was our first post, at the time there were only 69 subscribers, but now there are so many ppl, who also become part of this family 🥰
ሁላችሁንም ስለ አብሮነታችሁ፣ የጉዟችን አካል ስለሆናችሁ እናመሰግናለን!
@python_pioneers
🔥3
Forwarded from Abiy Ahmed Ali 🇪🇹
በዲጂታል ኢትዮጵያ ጉዞ አንድ እመርታ የታየበት ደረጃ ላይ ደርሰናል። ኢትዮ ቴሌኮም ከቪዛ ኩባንያ ጋር በመተባበር በኢትዮዽያ የመጀመሪያውን በኪስ የሚያዝ 'ቨርቱዋል ቪዛ' ካርድ ብሎም የተሻሻለ የሀዋላ አገልግሎት በቪዛ ዳይሬክት እና በቴሌብር ረሚት አቅርቧል።
ቪዛ ዳይሬክት ከ190 ሀገራት በላይ ቀለል ያለ የገንዘብ ማዘዋወር አገልግሎትን በቴሌብር ቨርቱዋል ካርድ ቁጥር አማካኝነት የሚያቀላጥፍ ይሆናል። ይህ አዲስ አገልግሎት ከ47.55 ሚሊዮን በላይ የሆኑ የቴሌብር ተጠቃሚዎችን ያገለግላል። ኢትዮ ቴሌኮም ትልቅ ስራ ሰርቷል።
A significant milestone in our Digital Ethiopia journey has been achieved with Ethio telecom, in partnership with Visa Inc., launching the country's first wallet-based Virtual Visa Card and enhanced remittance services via Visa Direct and telebirr Remit.
Visa Direct facilitates easy money transfers to Ethiopia from over 190 countries using a telebirr virtual card number. This partnership supports over 47.55 million telebirr users and advances Ethiopia's digital financial services. Well done to EthioTelecom!
ቪዛ ዳይሬክት ከ190 ሀገራት በላይ ቀለል ያለ የገንዘብ ማዘዋወር አገልግሎትን በቴሌብር ቨርቱዋል ካርድ ቁጥር አማካኝነት የሚያቀላጥፍ ይሆናል። ይህ አዲስ አገልግሎት ከ47.55 ሚሊዮን በላይ የሆኑ የቴሌብር ተጠቃሚዎችን ያገለግላል። ኢትዮ ቴሌኮም ትልቅ ስራ ሰርቷል።
A significant milestone in our Digital Ethiopia journey has been achieved with Ethio telecom, in partnership with Visa Inc., launching the country's first wallet-based Virtual Visa Card and enhanced remittance services via Visa Direct and telebirr Remit.
Visa Direct facilitates easy money transfers to Ethiopia from over 190 countries using a telebirr virtual card number. This partnership supports over 47.55 million telebirr users and advances Ethiopia's digital financial services. Well done to EthioTelecom!
👍1
What are Tuples?
Tuple በpython የobjects ስብስብ ሲሆን ባለፈው እንደተማርነው we can't change the order of the items in it.
Objectኦቹ strings, lists, tuples, integers etc. ሊሆኑ ይችላሉ።
የTuple insertion characteristics preserved ነው፣ once elements ካስቀመጥን we can't modify them.
Elements ከtuple የምናገኘው መጀመሪያ ባስቀመጥንበት order ነው።
ከlist የሚለያቸው ነገር ቢኖር ይህ ነው ፡ immutable መሆናቸው።
Tuple duplicate data store ማረግ ይችላል unlike set.
Tuple ተመሳሳይም ሆነ የተለያየ data type store ያረጋሉ እንደ list ማለት ነው
to be cont'd...
#Tuple
@python_pioneers
👍4