Python Pioneers: A Beginner's Guide 🇪🇹 – Telegram
Python Pioneers: A Beginner's Guide 🇪🇹
8.88K subscribers
345 photos
39 videos
24 files
61 links
Welcome to Python Pioneers: Empowering Ethiopian students to embark on their coding journey. 🚀🌐🗺📱🖥💻🖱🛰

DM 📩 : @MntsntZP
Download Telegram
በቀጣይ: IF-ELSE STATEMENT IN PYTHON

Stay Tuned!

@python_pioneers
@python_pioneers
Here is the data from the survey we conducted regarding the first digital language our channel members learned.

Most of the voters learned C++ first.

147 votes so far

@python_pioneers
1😁1
IF-ELSE STATEMENT IN PYTHON

በባለፈው ትምህርታችን ስለ if statement in python ማለትም አንድ condition ላይ በመመስረት የconditionኡን Truth value በማየት የተለያዩ code blocks run እንድናረግ እንደሚረዳን በትንሹም ቢሆን አይተናል፣ ዛሬ ደግሞ ከዛ የቀጠለውን ትምህርት እንማራለን።

ይህ የ if-else statement ለ decision-making ከsimple if statement የሚሻል አግልግሎት ይሰጣል። ከif statement ጋር በተመሳሳይ መንገድ ነው የሚሰራው ነገር ግን የsimple if statement condition Truth value False(ሀሰት) ከሆነ ምንም ነገር አናገኝም(nothing will be printed) ማለትም it does nothing: ነገር ግን if-else statement ስንጠቀም የif condition False ከሆነ የelse block ውስጥ ያለው expression executed ይሆናል።

እስኪ በምሳሌ እንየው:

አንድ kutir የሚባል variable አለን እንበል፣ እናም ለvariable assign የተደረገው ቁጥር even እንደሆነ እናረጋለን።
So here is the code for it: መጀመሪያ ለvariableኡ የሰጠነው value 4 ነው። የተጠቀምነው condition ደግሞ (kutir % 2 == 0) ነው፣ ይህ ደግሞ variableኡ ውስጥ የተያዘው ቁጥር even እንደሆነ check ለማድረግ ነው(A number is even if it is divided by two without a remainder)

Here is the code:

kutir = 4

if kutir % 2 == 0:
print("kutir is Even")


Output : kutir is Even


እዚህ ጋር conditionኡ እውነት ስለሆነ( 4 even ስለሆነ) the block of code inside the if statement is executed in this case "kutir is Even" printed ይሆናል።

ግን እሺ what will happen if we change the value of the variable to 3?

የvariableኡ value 3 ከሆነ the condition becomes False ያ ማለት the statement under if block is not executed( nothing will be printed) ማለት ነው። እዚህ ጋር ነው ታዲያ else block የሚያስፈልገው።


kutir = 3

if kutir % 2 == 0:
print("kutir is Even")


Output :

ከላይ ያለውን code if-else statement ተጠቅመን ከፃፍነው።የ if statement condition False ስለሆነ፣ else block ውስጥ ያለው code executed ይሆናል ማለት ነው። ቁጥሩ even ካልሆነ "kutir is not even" የሚል text printed እንዲሆንልን ከፈለግን እንደዚህ መፃፍ እንችላለን።

kutir = 3

if kutir % 2 == 0:
print("kutir is Even")
else:
print("kutir is not Even")


Output :kutir is not Even


3 even ስላልሆነ if block ውስጥ ያለው code ይዘለልና else block ውስጥ ያለው code executed ይሆናል-> "kutir is not Even" printed ይሆናል ማለት ነው።

ቀጣይ: if..elif..else

Pythonን በአማርኛ እንማር!

#IfElse

@python_pioneers
@python_pioneers
2👍2
Here are some beautiful programming related wallpapers.

Enjoy Them!⚡️⚡️⚡️⚡️

#wallpapers

@python_pioneers
🔥31👍1👌1
"To attract positive things in your life, start by giving off positive energy."

-Unkown

Have a nice day!

#EnglishQoutes

@python_pioneers
3👍2
"መልካም ያደረጉ ብዙ
ሴቶች አሉ አንቺ ግን
ከሁሉ ትበልጫለሽ"

"Many women do
noble things but
you surpass them all"

--> @nirvanaland7

መልካም የእናቶች ቀን!

#MothersDay
@python_pioneers
7👍1👎1
if...elif…else statement

if...elif…else statement: ብዙ አማራጮች ሊኖሩት የሚችል ወይም ብዙ conditions የሚፈልግ problem ካለ ይሄን መንገድ እንጠቀማለን ።

በተማሪ ውጤት ላይ በመመስረት 'Excellent, Very Good, Good, Satisfactory, or Fail’ ብሎ print የሚያረግ program ለመስራት አስበናል እንበል።

በእንደዚህ ዓይነት ሁኔታዎች ፣ የፈለግነውን ያህል elif statement ተጠቅመን ለተለያዩ conditions የተለያዩ executions እንዲኖሩት Pythonን በመጠቀም ማድረግ እንችላለን።

else is the same as else and if combined together

Multiple if's means your code would go and check all the if conditions, where as in case of elif, if one if condition satisfies it would not check other conditions..

የ elif keyword በPython interpreterኡን "ከዚህ ቀደም ያለው condition(s) እውነት ካልሆነ/ኑ ይሄኛውን ሞክር" እንደማለት ነው። or " else...if" ማለት ነው።

በምሳሌ እንየው:

Pseudocode:

if condition1:
#statement to execute if condition1 is true
elif condition2:
#statement to execute if condition2 is true
else:
#statement to execute if both conditions are false

የመጀመሪያው condition true ከሆነ, በif block ውስጥ ያለው statement executed ይሆናል።

የመጀመሪያው condition false ከሆነ , ቀጣዩ elif condition check ይደረጋል።

የelif condition true ከሆነ, በelif block ውስጥ ያለው statement executed ይሆናል።

ሁለቱም conditions false ከሆኑ ደግሞ , በelse block ውስጥ ያለው statement executed ይሆናል።

...ይቀጥላል

#Condional

@python_pioneers
በቀጣይ elif statement በመጠቀም የተማሪን👨‍💻👩‍💻👨‍🎓 Performance መሰረት በማድረግ grade እንድንሰጥ የሚያስችለንን program እንዴት መፃፍ እንደምንችል እናያለን።

⏭️
የPythonን elif statement በመጠቀም ሊቀረፍ የሚችል real-life problem ቢኖር Grading system ነው።

Here's an example:

# Program to calculate the grade of a student based on their exam score

# declaring a variable to store exam score
exam_score = 87

# Calculate grade based on exam score
if exam_score >= 90:
grade = "A"
elif exam_score >= 80:
grade = "B"
elif exam_score >= 70:
grade = "C"
elif exam_score >= 60:
grade = "D"
else:
grade = "F"

# Display the grade
print("The grade for the exam score of ", exam_score, "is", grade)

በዚህ program, exam_score variable የተማሪውን ውጤት ከመቶ ይቀበላል(ወይም user-input እንዲቀበል ማድረግ እንችላለን ይህ ደግሞ for multiple scores grade check እንድናረግ ይረዳናል) ከዛም programኡ በውጤቱ ልክ grade ይሰጠናል።

The elif statements help determine the appropriate grade based on different score ranges. Finally, the grade is displayed.

ጥያቄ ካላችሁ መጠየቅ ትችላላችሁ

⏭️በቀጣይ input ከ user እንዴት መቀበል እንደምንችል እንማራለን

ትምህርቶቹን ከወደዳችኋቸው በ👍 ግለፁልን

#elif
#example

@python_pioneers
@python_pioneers
👍8🥰1