2. Which of the following variable names is invalid in Python?
Anonymous Quiz
14%
a) my_variable
64%
b) 2nd_variable
11%
c) variable2
11%
d) _variable
3. What is the correct way to assign a value of 5 to a variable named "x" in Python?
Anonymous Quiz
86%
a) x = 5
3%
b) 5 = x
10%
c) x == 5
0%
d) x := 5
4. What happens if you try to access a variable that has not been defined in Python?
Anonymous Quiz
29%
a) It raises a SyntaxError
15%
b) It creates a new variable with that name
38%
c) It raises a NameError
17%
d) It returns None
👍2
5. In Python, is it possible to assign multiple variables in a single line?
Anonymous Quiz
74%
a) Yes, using comma-separated values
11%
b) No, Python does not support multiple variable assignment
10%
c) Yes, but only for integers
4%
d) Yes, but only for strings
👍2
OPERATIONS IN PYTHON
Here are some of the fundamental operations in python. Mathematics ላይ ካየን there are operations like addition , subtraction... እነዚህን operations Arithmetic operations እንላቸዋለን፣ Python ግን Arithmetic operations ላይ የተገደበ አይደለም፣ There are lots of operations.
Operands: Operands are the values or variables on which an operator acts. In other words, operands are the data that are manipulated by an operator in an expression.
ለምሳሌ፡ In the expression 5 + 3, the _operands_ are the numbers 5 and 3, while the plus sign (+) is the _operator_ that acts on the _operands_ to perform the addition operation.
በ Python ደግሞ operands variables, constants, ወይም expressions ሊሆኑ ይችላሉ።
1. Arithmetic Operations:
- Addition (+): ሁለት ቁጥሮችን ለመደመር የምንጠቀመው type of operation ነው።.
- Subtraction (-): ከመጀመሪያው ቁጥር ሁለተኛውን ለመቀነስ የሚያገለግል operation ነው።
- Multiplication (*): ይህኛው ደግሞ ሁለት operands ለማባዛት፡
- Division (/): የመጀመሪያውን ቁጥር በሁለተኛው ቁጥር ለማካፈል ያገለግላል(The result is always a float).
- Modulus (%): Returns the remainder of the division(ቀሪ return ያረጋል)
- Exponentiation (**): Raises the first operand to the power of the second.
x**y ማለት x to the power of y እንደ ማለት ነው።
- Floor Division (//): Returns the quotient without the remainder(ክፍልፋይ ያለ ቀሪ return ያረጋል)
Code Example:
2. Comparison Operations:
እነዚህ operations ደግሞ ሁለት values(operands) compare በማድረግ boolean value return ያረጋሉ (True or False) based on on the comparison result.
- Equal (==): Checks if two operands are equal.
- Not Equal (!=): Checks if two operands are not equal.
- Greater Than (>): Checks if the first operand is greater than the second.
- Less Than (<): Checks if the first operand is less than the second.
- Greater Than or Equal To (>=): Checks if the first operand is greater than or equal to the second.
- Less Than or Equal To (<=): Checks if the first operand is less than or equal to the second.
Code Example:
...ይቀጥላል
@python_pioneers
@python_pioneers
Here are some of the fundamental operations in python. Mathematics ላይ ካየን there are operations like addition , subtraction... እነዚህን operations Arithmetic operations እንላቸዋለን፣ Python ግን Arithmetic operations ላይ የተገደበ አይደለም፣ There are lots of operations.
Operands: Operands are the values or variables on which an operator acts. In other words, operands are the data that are manipulated by an operator in an expression.
ለምሳሌ፡ In the expression 5 + 3, the _operands_ are the numbers 5 and 3, while the plus sign (+) is the _operator_ that acts on the _operands_ to perform the addition operation.
በ Python ደግሞ operands variables, constants, ወይም expressions ሊሆኑ ይችላሉ።
1. Arithmetic Operations:
- Addition (+): ሁለት ቁጥሮችን ለመደመር የምንጠቀመው type of operation ነው።.
- Subtraction (-): ከመጀመሪያው ቁጥር ሁለተኛውን ለመቀነስ የሚያገለግል operation ነው።
- Multiplication (*): ይህኛው ደግሞ ሁለት operands ለማባዛት፡
- Division (/): የመጀመሪያውን ቁጥር በሁለተኛው ቁጥር ለማካፈል ያገለግላል(The result is always a float).
- Modulus (%): Returns the remainder of the division(ቀሪ return ያረጋል)
- Exponentiation (**): Raises the first operand to the power of the second.
x**y ማለት x to the power of y እንደ ማለት ነው።
- Floor Division (//): Returns the quotient without the remainder(ክፍልፋይ ያለ ቀሪ return ያረጋል)
Code Example:
a = 10
b = 5
addition = a + b # result = 15
subtraction = a - b # result = 5
multiplication = a * b # result = 50
division = a / b # result = 2.0
modulus = a % b # result = 0 since the rem is 0
exponentiation = a ** b # result = 100000
floor_division = a // b # result = 2
2. Comparison Operations:
እነዚህ operations ደግሞ ሁለት values(operands) compare በማድረግ boolean value return ያረጋሉ (True or False) based on on the comparison result.
- Equal (==): Checks if two operands are equal.
- Not Equal (!=): Checks if two operands are not equal.
- Greater Than (>): Checks if the first operand is greater than the second.
- Less Than (<): Checks if the first operand is less than the second.
- Greater Than or Equal To (>=): Checks if the first operand is greater than or equal to the second.
- Less Than or Equal To (<=): Checks if the first operand is less than or equal to the second.
Code Example:
x = 10
y = 5
equal = x == y # result = False since 10 != 5
not_equal = x != y # result = True since 10 != 5
greater_than = x > y # result = True since 10 > 5
less_than = x < y # result = False since 10 > 5
greater_than_or_equal_to = x >= y # result = True
less_than_or_equal_to = x <= y # result = False
...ይቀጥላል
@python_pioneers
@python_pioneers
👍4👏2
...contd
3. Logical Operations:
The operands here are boolean values (True and False).
- AND (and): Returns True if both operands are true.
- OR (or): Returns True if any of the operands are true.
- NOT (not): Returns True if the operand is false.
Code Example:
4. Assignment Operations:
እነዚህ ደግሞ አንድን value ለvariable assign ለማድረግ ነው የምንጠቀመው።
+= : በቀኝ በኩል ያለውን operand በግራ በኩል ባለው operand ላይ ይደምርና ውጤቱን በግራ በኩል ላለው operand assign ያረገዋል።
-= : በቀኝ በኩል ያለውን operand ከግራው በመቀነስ ውጤቱን በግራ በኩል ላለው operand assign ያረጋል።
*= : በግራ በኩል ያለውን operand በቀኝ በኩል ባለው ያባዛና ውጤቱን በግራ በኩል ላለው operand assign ያረጋል።
/= : በግራ በኩል ያለውን operand በቀኝ በኩል ባለው operand ያካፍልና ውጤቱን በግራ በኩል ላለው operand assign ያረገዋል።
Code Example:
These are just some of the basic operations in python, we believe you have grasped some knowledge about them.
@python_pioneers
@python_pioneers
3. Logical Operations:
The operands here are boolean values (True and False).
- AND (and): Returns True if both operands are true.
- OR (or): Returns True if any of the operands are true.
- NOT (not): Returns True if the operand is false.
Code Example:
p = True
q = False
and_result = p and q # result = False
or_result = p or q # result = True
not_result = not p # result = False
4. Assignment Operations:
እነዚህ ደግሞ አንድን value ለvariable assign ለማድረግ ነው የምንጠቀመው።
+= : በቀኝ በኩል ያለውን operand በግራ በኩል ባለው operand ላይ ይደምርና ውጤቱን በግራ በኩል ላለው operand assign ያረገዋል።
-= : በቀኝ በኩል ያለውን operand ከግራው በመቀነስ ውጤቱን በግራ በኩል ላለው operand assign ያረጋል።
*= : በግራ በኩል ያለውን operand በቀኝ በኩል ባለው ያባዛና ውጤቱን በግራ በኩል ላለው operand assign ያረጋል።
/= : በግራ በኩል ያለውን operand በቀኝ በኩል ባለው operand ያካፍልና ውጤቱን በግራ በኩል ላለው operand assign ያረገዋል።
Code Example:
x = 5
x += 3 # Equivalent to x = x + 3
x -= 2 # Equivalent to x = x - 2
x *= 4 # Equivalent to x = x * 4
x /= 2 # Equivalent to x = x / 2
These are just some of the basic operations in python, we believe you have grasped some knowledge about them.
@python_pioneers
@python_pioneers
👍3❤1
GROW THROUGH WHAT YOU GO THROUGH.
የሚያጋጥመን ማንኛውም ፈተና እና መሰናክል ለመማር፣ ለማደግ እና ለመጠንከር እድል ይሰጠናል። በሚያጋጥሙን ችግሮች ከመማረር ወይም ከመናደድ ይልቅ ለself development እና እራሳችንን ለማሻሻል እንደ እድል አድርገን መቀበል አለብን።
መልካም ምሽት!
@python_pioneers
የሚያጋጥመን ማንኛውም ፈተና እና መሰናክል ለመማር፣ ለማደግ እና ለመጠንከር እድል ይሰጠናል። በሚያጋጥሙን ችግሮች ከመማረር ወይም ከመናደድ ይልቅ ለself development እና እራሳችንን ለማሻሻል እንደ እድል አድርገን መቀበል አለብን።
መልካም ምሽት!
@python_pioneers
👍5🥰2
Python Pioneers: A Beginner's Guide 🇪🇹
COMMENTS IN PYTHON Pythonን በአማርኛ እንማር! Stay Tuned! @python_pioneers
COMMENTS IN PYTHON
በPython፡ Comments በPython interpreter ignore የሚደረጉ ማብራሪያዎች ናቸው። የፃፍነውን code purpose ለመግለፅ፣ እንዴት እንደሚሰራ፣ እና ሌሎች መረጃዎችን ለመፃፍ እንጠቀማቸዋለን። Comments are crucial for code readability and maintenance
TYPES OF COMMENTS IN PYTHON፡-
1. Single-Line Comments፡ እነዚህ comments በ
2. Multi-Line Comments፡ በPython ፣ ለMulti-line comments specific syntax የለም። ነገር ግን አብዛኛውን ጊዜ multi-line comments ለመፍጠር triple qoutes(ሶስት ትምህርተ ጥቅስ)(''' ወይም """) መጠቀም እንችላለን።
3. Docstrings፡ Docstrings፡ functions, modules, እና classes document ለማድረግ ይጠቅማሉ። They are enclosed in triple quotes and provide more detailed explanations of the purpose, parameters, and return values of functions.
ለምሳሌ ይሄንን code እንመልከት፡
እናም in general comments in any programming languages የሚያገለግሉት የፃፍነው code በምን ዓይነት መንገድ እንደሚሰራ ለመግለፅ ነው፣ የፃፍነውን code ደግሞ ለላ ሰው እንዲያየው share የምናረግ ከሆነ የሚያነበው ሰው የበለጠ ስለ programኡ አሰራር እንዲረዳ ያደርጋል።
@python_pioneers
በPython፡ Comments በPython interpreter ignore የሚደረጉ ማብራሪያዎች ናቸው። የፃፍነውን code purpose ለመግለፅ፣ እንዴት እንደሚሰራ፣ እና ሌሎች መረጃዎችን ለመፃፍ እንጠቀማቸዋለን። Comments are crucial for code readability and maintenance
TYPES OF COMMENTS IN PYTHON፡-
1. Single-Line Comments፡ እነዚህ comments በ
# ምልክት ይጀምራሉ እና እስከ line መጨረሻ ድረስ ይቀጥላሉ ። እነዚህን ደግሞ ለአጫጭር ማብራሪያዎች እንጠቀማቸዋለን።# This is a single-line comment
x = 5 # This is also a single-line comment
2. Multi-Line Comments፡ በPython ፣ ለMulti-line comments specific syntax የለም። ነገር ግን አብዛኛውን ጊዜ multi-line comments ለመፍጠር triple qoutes(ሶስት ትምህርተ ጥቅስ)(''' ወይም """) መጠቀም እንችላለን።
'''
This is a multi-line comment.
It spans across multiple lines.
'''
3. Docstrings፡ Docstrings፡ functions, modules, እና classes document ለማድረግ ይጠቅማሉ። They are enclosed in triple quotes and provide more detailed explanations of the purpose, parameters, and return values of functions.
ለምሳሌ ይሄንን code እንመልከት፡
def add_numbers(a, b):
"""
This function adds two numbers together.
Parameters:
a (int): The first number.
b (int): The second number.
Returns:
int: The sum of a and b.
"""
return a + b
እናም in general comments in any programming languages የሚያገለግሉት የፃፍነው code በምን ዓይነት መንገድ እንደሚሰራ ለመግለፅ ነው፣ የፃፍነውን code ደግሞ ለላ ሰው እንዲያየው share የምናረግ ከሆነ የሚያነበው ሰው የበለጠ ስለ programኡ አሰራር እንዲረዳ ያደርጋል።
@python_pioneers
👍3
There is no straight path to success. The problems we face have the ability to shape us. Grow through them.
HARD WORK
|
|
PROBLEM
|
SETBACK
|
FAILURE
|
CHALLENGE
|
OBSTACLE
|
|
SUCCESS
Have a nice day!
@python_pioneers
HARD WORK
|
|
PROBLEM
|
SETBACK
|
FAILURE
|
CHALLENGE
|
OBSTACLE
|
|
SUCCESS
Have a nice day!
@python_pioneers
👍1
Let's Revise what we have been learning with these questions.
👇👇👇👇👇👇👇👇👇
👇👇👇👇👇👇👇👇👇
1. What is the correct way to declare a variable in Python?
Anonymous Quiz
7%
A. var x = 5
66%
B. x = 5
25%
C. int x = 5
2%
D. declare x as 5
2. What is the purpose of comments in Python code?
Anonymous Quiz
6%
A. To make the code run faster
85%
B. To explain the purpose of the code
6%
C. To hide code from other programmers
3%
D. To declare variables
3. What type of operations can you perform on variables in Python?
Anonymous Quiz
12%
A. Mathematical operations
6%
B. String operations
0%
C. Logical operations
82%
D. All of the above
4. What is the difference between declaring a variable and assigning a value to it in Python?
Anonymous Quiz
19%
A. There is no difference
48%
B. Declaring initializes with a value, assigning a value changes the value of an existing variable
29%
C. Declaring a variable creates a variable, while assigning a value creates a new variable
4%
D. Assigning a value is only done with strings
5. What is the significance of using an underscore (_) in variable names in Python?
Anonymous Quiz
22%
A. It indicates a reserved word
65%
B. It separates words in a variable name
6%
C. It is not allowed in variable names
6%
D. It is used for mathematical operations
👌1
🔈New Subscribers
Welcome!
It is good for you if you scroll up and see the previous lessons we have been learning.
Also don't forget to invite your friends ,who are interested in programming, to our channel.
@python_pioneers
Welcome!
It is good for you if you scroll up and see the previous lessons we have been learning.
Also don't forget to invite your friends ,who are interested in programming, to our channel.
@python_pioneers
Python Pioneers: A Beginner's Guide 🇪🇹 pinned «🔈New Subscribers Welcome! It is good for you if you scroll up and see the previous lessons we have been learning. Also don't forget to invite your friends ,who are interested in programming, to our channel. @python_pioneers»
1⃣0⃣1⃣0⃣1⃣1⃣0⃣1⃣0⃣1⃣1⃣0⃣1⃣1⃣1⃣0⃣1⃣0⃣
Test your knowledge about arithmetic operations in python with these easy questions ❓❓❓❓❓
Test your knowledge about arithmetic operations in python with these easy questions ❓❓❓❓❓