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
SCRIPT MODE

Interactive mode የፃፍነውን code test ለማድረግ ጠቃሚ ቢሆንም በዚህ mode ምንፅፋቸው codes saved አይሆኑም። They are simply executed and their results displayed on the screen.

Python statements እንደ program save ለማድረግ፣ you save those statements in a file፣ ከዛም python Interpreter በnoscript mode በመጠቀም የፃፍነውን code execute ማድረግ እንችላለን።

For example, suppose you want to write a Python program that displays the following three lines of text:

My name is Abebe.
I am 25 years old.
I am a university student.

Programኡን ማንኛውንም አይነት text editor መፃፍ እንችላለን፣ ፅፈን ስንጨርስ ደግሞ programኡን የፃፍንበትን file with the .py extension save እናረገዋለን።

print('My name is Abebe.')
print('I am 25 years old.')
print('I am a university student.')

ለምሳሌ fileኡን በዚህ ስም save አርገናል እንበል: ethio.py

የፃፍነውን program run ለማድረግ ደግሞ ወደ operating systemኡ command-line በመሄድ fileኡ ያለበት folder ውስጥ እንደሚከተለው እንፅፋለን፡

python ethio.py

This starts the Python interpreter in noscript mode and causes it to execute the statements in the file ethio.py. When the program finishes executing, the Python interpreter exits.

And here is the output:

My name is Abebe.
I am 25 years old.
I am a university student.


...እንቀጥላለን

@python_pioneers
👍1
DATA TYPES IN PYTHON

In Python, data types የተለያዩ የመረጃ አይነቶችን categorize እንድናረግ ይረዱናል፡ such as numbers, strings, lists, tuples, and dictionaries.

እናም ስለ data types ያለን understanding for efficient data manipulation እና memory allocation አስፈላጊ ነው።

Here are some common data types in Python:

1. Integer(int):
ይሄ data type represent የሚያረገው decimal point የሌላቸውን ቁጥሮች ነው።

ለምሳሌ : 5, -10, 100

2. Floating-point(float):

ይሄ data type ደግሞ represent የሚያረገው ነጥብ(decimal point) ያላቸውን ቁጥሮች ነው።

ለምሳሌ : 3.14, -2.5, 100.0

3. String(str):

Represent የሚያረገው በquotation marks(single, double or triple) enclosed የሆኑ textኦችን ነው።

ለምሳሌ : 'Python', "Pioneers", '''Ethiopia'''

4. Boolean(bool):

Represents one of two values, True(1) or False(0).

ለምሳሌ: True, False

5. List:

Represents a collection of elements that can be of different data types. በ square bracket ነው የሚሸፈነው, being itself a data type ሌሎችንም አይነት data types በውስጡ ይይዛል።

ለምሳሌ : [1, 'pioneers', True]

6. Tuple:

ከlist ጋር ተመሳሳይ ቢሆንም it is immutable (ማለትም we can not change its contents). በ bracket ይሸፈናል።

ለምሳሌ: (1, 'name', False)

7. Dictionary:

በkey-value መንገድ የተያያዙ data types represent ያረጋል፣ one pointing the other. It is enclosed with curly brackets.

ለምሳሌ: {'name': 'Abebe', 'age': 30}

የአንድን variable(we will learn about them) data type ለማወቅ 'type()' የሚባል built-in function(It is a type of function which is already present in the interpreter as a part of the standard library) እንጠቀማለን።

ለምሳሌ:

x = 10
print(type(x)) # Output: <class 'int'>

TRY IT!

Understanding and manipulating different data types in Python is crucial for writing effective and efficient code.

It also helps in ensuring the correct interpretation and handling of data throughout a program.

ስለ እያንዳንዱ data type በቀጣይ እንማራለን

@python_pioneers
@python_pioneers
👍2
እስኪ ይህችን ታራክ አንብቧት

Three Feet From Gold:

During the gold rush, a man who had been mining in Colorado for several months quit his job, as he hadn’t struck gold yet and the work was becoming tiresome.

He sold his equipment to another man who resumed mining where it had been left off. The new miner was advised by his engineer that there was gold only three feet away from where the first miner stopped digging.

The engineer was right, which means the first miner was a mere three feet away from striking gold before he quit.

The Moral:

When things start to get hard, try to persevere through the adversity. Many people give up on following their dreams because the work becomes too difficult, tedious, or tiresome–but often, you’re closer to the finish line than you may think, and if you push just a little harder, you will succeed.

መልካም ምሽት!♥️

#English_Stories

@python_pioneers
👍6
VARIABLES IN PYTHON

በቀጣይ በPython ስለ variables ምንነት እንማራለን።

Stay Tuned!

@python_pioneers
@python_pioneers
👍3
VARIABLES IN PYTHON

In Python, Variables data values store ለማረግ ነው የሚያገለሉት። በMathematics ካየን a variable is a symbol that represents a number፡ አብዛኛውን ጊዜ ደግሞ ፊደል ነው። በተመሳሳይ፡ variable በpython ለሆነ data value መጠሪያ ነው፡ it can be a single letter or a word.

1. Variable Declaration: You declare variables in Python simply by assigning a value to them using the = sign. Variable declare ስናረግ በcomputerኡ memory ውስጥ የምንፈልገውን value store የምናረግበት space ይፈጠራል።

It is like የሆነ ሳጥን አላችሁ እንበል፣ ከዛ ስም ትሰጡታላችሁ፣ እናም የፈለጋችሁትን ነገር ሳጥኑ ውስጥ ማረግ ትችላላችሁ so think the same way about variables.

x = 5

2. Variable Naming Rules:
-የvariable ሥም ፊደል፣ ቁጥር እና underscore(_) መያዝ ይችላል።
- የvariable ሥም በቁጥር መጀመር አይቻልም።
- Variable names case-sensitive ናቸው። ማለትም ለምሳሌ age እና Age አንድ አይነት variable አይደሉም።

my_variable = "Hello"

3. Data Types: Python is dynamically typed, ማለትም የvariableኡን data type declare ማረግ አይጠበቅብንም። Python automatically የሚገባውን data በማየት የvariableኡን data type assign ያረጋል፣ ይሄ ግን ለሁሉም programming languages የሚሰራ አይደለም።

ለምሳሌ፡ difference in variable declaration between Java and Python እንይ፡

Declaring a variable in Java

int x = 5;

በዚህ ጊዜ variable declare ስናረግ data typeኡንም assign ማረግ ይኖርብናል። ግን we don't need to do this in python, since it automatically assigns the type of data at the instant we give it a value.

Declaring a variable in Python:

x = 5

Let's assign different data types to a variable in python

x = 5  # x is an integer
y = 3.14 # y is a float
z = "Hello" # z is a string

4. Variable Reassignment: You can reassign a variable to a different value. ተምሳሳይ variable በመጠቅም value reassign ማረግ እንችላለን፣ that means we can give it another value.

x = 5
x = 10 # x is now assigned the value 10
# x is no more 5

...ይቀጥላል

Practice by assigning different values for variables.

Don't forget to invite your friends

@python_pioneers
@python_pioneers
👍5🙏2
Forwarded from Luna's pathway🤗 (Luna)
#Quote of the day
3
Multiple-choice questions pertaining to variable usage in Python.

Test your knowledge about variables with the following questions
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
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:

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:

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
👍31
GROW THROUGH WHAT YOU GO THROUGH.

የሚያጋጥመን ማንኛውም ፈተና እና መሰናክል ለመማር፣ ለማደግ እና ለመጠንከር እድል ይሰጠናል። በሚያጋጥሙን ችግሮች ከመማረር ወይም ከመናደድ ይልቅ ለself development እና እራሳችንን ለማሻሻል እንደ እድል አድርገን መቀበል አለብን።

መልካም ምሽት!

@python_pioneers
👍5🥰2
COMMENTS IN PYTHON

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

Stay Tuned!
@python_pioneers
👍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 በ# ምልክት ይጀምራሉ እና እስከ 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
👍1
Let's Revise what we have been learning with these questions.
👇👇👇👇👇👇👇👇👇