# data[].attributes.body
انتهاز الفرصة في المشاركة في مسابقة مكتب العارض لتسليم مشاريع الانفوجرافيك المطلوبة من الطالبة ..

عبير المطلق .. المتوسطة ١٦٠

# data[].attributes.headline
online-python ( للمدارس التي  لا  يتوفر فيها معمل الحاسب )

# data[].attributes.subject
online-python ( للمدارس التي  لا  يتوفر فيها معمل الحاسب )

# data[].attributes.body
د. هيفاء الجعيد

# data[].attributes.headline
مشاريع طالباتي الصف ثالث متوسط  في الوحدة الأول ( أبحث عن معلوماتي) الهدف منها :-إكساب الطالبات مهارة البحث .إكساب الطالبات مهارات الرصانة والدقة في البحث عن المعلومات .تعزيز مفهوم الملكية الفكرية بتوثيق المراجع .

# data[].attributes.subject
مشاريع طالباتي الصف ثالث متوسط  في الوحدة الأول ( أبحث عن معلوماتي) الهدف منها :-إكساب الطالبات مهارة البحث .إكساب الطالبات مهارات الرصانة والدقة في البحث عن المعلومات .تعزيز مفهوم الملكية الفكرية بتوثيق المراجع .

# data[].attributes.body
د. هيفاء الجعيد

# data[].attributes.attachment_link.description
مشاريع الصف الثالث متوسط

# data[].attributes.headline
مشاريع طالبات الصف الثاني متوسط الوحدة الأولى  (إنتاج مقطع فيديو  ) 

# data[].attributes.subject
مشاريع طالبات الصف الثاني متوسط الوحدة الأولى  (إنتاج مقطع فيديو  ) 

# data[].attributes.body
د. هيفاء الجعيد

# data[].attributes.attachment_link.description
مشاريع طالبات المرحلة المتوسطة

# data[].attributes.headline
مبادرة المدربة المتعاونة في وحدة البرمجة والتصميم 

# data[].attributes.subject
مبادرة المدربة المتعاونة في وحدة البرمجة والتصميم 

# data[].attributes.body
د. هياء الجعيد

# data[].attributes.attachment_link.title
مبادرة المدربة المتعاونة 

# data[].attributes.headline
بدائل تعليمية للصف الثالث متوسط ( استخدام الذكاء الاصطناعي في تصميم المواقع )

# data[].attributes.subject
بدائل تعليمية للصف الثالث متوسط ( استخدام الذكاء الاصطناعي في تصميم المواقع )

# data[].attributes.attachment_link.title
بدائل تعليمية للصف الثالث المتوسط ( واجهتي للعالم)

# data[].attributes.headline
Python program to calculate grade of student 

# data[].attributes.subject
Python program to calculate grade of student 

# data[].attributes.body
د. هيفاء الجعيد

# data[].attributes.attachment_link.title
Python program to calculate grade of student as per marks obtained

# data[].attributes.attachment_link.description
In this python programming article, we are going to learn python program to calculate grade of student Here we are going to write python program to find grade of a student based on the marks obtained by student. This code will use decision making statement if-ef-else concept in python.

# data[].attributes.body
د. هيفاء الجعيد

# data[].attributes.attachment_link.readable_text
while loop repeats the sequence of actions many times until some condition evaluates to False. The condition is given before the loop body and is checked before each execution of the loop body. Typically, the while loop is used when it is impossible to determine the exact number of loop iterations in advance.

The syntax of the while loop in the simplest case looks like this:

while some condition:
    a block of statements

Python firstly checks the condition. If it is False, then the loop is terminated and control is passed to the next statement after the while loop body. If the condition is True, then the loop body is executed, and then the condition is checked again. This continues while the condition is True. Once the condition becomes False, the loop terminates and control is passed to the next statement after the loop.

For example, the following program fragment prints the squares of all integers from 1 to 10. Here one can replace the "while" loop by the for ... in range(...) loop:

i = 1
while i <= 10:
    print(i ** 2)
    i += 1

In this example, the variable i inside the loop iterates from 1 to 10. Such a variable whose value changes with each new loop iteration is called a counter. Note that after executing this fragment the value of the variable i is defined and is equal to 11, because when i == 11 the condition i <= 10 is False for the first time.

Here is another example use of the while loop to determine the number of digits of an integer n:

n = int(input())
length = 0
while n > 0:
    n //= 10  # this is equivalent to n = n // 10
    length += 1
print(length)  # 4

On each iteration we cut the last digit of the number using integer division by 10 ( n //= 10). In the variable length we count how many times we did that.

In Python there is another, easier way to solve this problem: length = len(str(i)).

One can write an else: statement after a loop body which is executed once after the end of the loop:

i = 1
while i <= 10:
    print(i)
    i += 1
else:
    print('Loop ended, i =', i)

At the first glance, this statement doesn't seem to have sense, because the else: statement body can just be put after the end of the loop. "else" statement after a loop only has sense when used in combination with the instruction break. If during the execution of the loop Python interpreter encounters break, it immediately stops the loop execution and exits out of it. In this case, the else: branch is not executed. So, break is used to abort the loop execution during the middle of any iteration.

Here is a Black Jack-like example: a program that reads numbers and sums it until the total gets greater or equal to 21. The input sequence ends with 0 for the program to be able to stop even if the total sum of all numbers is less than 21.

Let's see how it behaves on the different inputs.

Version 1. The loop is exited normally after checking the condition, so the "else" branch is executed.

total_sum = 0
a = int(input())
while a != 0:
    total_sum += a
    if total_sum >= 21:
        print('Total sum is', total_sum)
        break
    a = int(input())
else:
    print('Total sum is less than 21 and is equal to', total_sum, '.')

Version 2. The loop is aborted by break, so the "else" branch is skipped.

total_sum = 0
a = int(input())
while a != 0:
    total_sum += a
    if total_sum >= 21:
        print('Total sum is', total_sum)
        break
    a = int(input())
else:
    print('Total sum is less than 21 and is equal to', total_sum, '.')

"Else" branch can also be used with the "for" loop. Let's look at the example when a program reads 5 integers but stops right when the first negative integer is met.

Version 1. The loop is exited normally, so the "else" branch is executed.

for i in range(5):
    a = int(input())
    if a < 0:
        print('Met a negative number', a)
        break
else:
    print('No negative numbers met')

Version 2. The loop is aborted, so the "else" branch isn't executed.

for i in range(5):
    a = int(input())
    if a < 0:
        print('Met a negative number', a)
        break
else:
    print('No negative numbers met')

Another instruction used to control the loop execution is continue. If Python interpreter meets continue somewhere in the middle of the loop iteration, it skips all the remaining instructions and proceeds to the next iteration.

for num in range(2, 10):
    if num % 2 == 0:
        print("Found an even number", num)
        continue
    print("Found a number", num)

If the break and continue are placed inside several nested loops, they affect only the execution of the innermost one. Let's look at rather silly example to demonstrate it:

for i in range(3):
    for j in range(5):
        if j > i:
            # breaks only the for on line 2
            break
        print(i, j)

The instructions break and continue are discouraged, if you can implement your idea without using them. Here is a typical example of a bad usage of the break: this code counts the number of digits in an integer.

n = int(input())
length = 0
while True:
    length += 1
    n //= 10
    if n == 0:
        break
print('Length is', length)

It's cleaner and easier-to-read to rewrite this loop with a meaningful loop condition:

n = int(input())
length = 0
while n != 0:
    length += 1
    n //= 10
print('Length is', length)

In Python it is possible for a single assignment statement to change the value of several variables. Let's see:

The effect demonstrated above code can be written as:

The difference between the two versions is that multiple assignment changes the values of two variables simultaneously.

Multiple assignment is useful when you need to exchange the values of two variables. In older programming languages without the support of multiple assignment this can be done using the auxiliary variable:

a = 1
b = 2
tmp = a
a = b
b = tmp
print(a, b)
# 2 1

In Python, the same swap can be written in one line:

a = 1
b = 2
a, b = b, a
print(a, b)
# 2 1

The left-hand side of "=" should have a comma-separated list of variable names. The right-hand side can be any expressions, separated by commas. The left-hand side and the right-hand side lists should be of equal length.

# data[].attributes.attachment_link.description
while loop repeats the sequence of actions many times until some condition evaluates to False. The condition is given before the loop body and is checked before each execution of the loop body. Typically, the while loop is used when it is impossible to determine the exact number of loop iterations in advance.

# data[].attributes.headline
شروحات مفصلة  للغة البايثون 

# data[].attributes.subject
شروحات مفصلة  للغة البايثون 

# data[].attributes.body
فالكم التوفيق اخواتي د. هيفاء الجعيد

# data[].attributes.attachment_link.readable_text
A function is a block of code which only runs when it is called.

You can pass data, known as parameters, into a function.

A function can return data as a result.

Creating a Function

In Python a function is defined using the def keyword:

Example

Calling a Function

To call a function, use the function name followed by parenthesis:

Example

my_function()

Try it Yourself "

Arguments

Information can be passed into functions as arguments.

Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma.

The following example has a function with one argument (fname). When the function is called, we pass along a first name, which is used inside the function to print the full name:

Example

Try it Yourself "

Arguments are often shortened to args in Python documentations.

Parameters or Arguments?

The terms parameter and argument can be used for the same thing: information that are passed into a function.

From a function's perspective:

A parameter is the variable listed inside the parentheses in the function definition.

An argument is the value that is sent to the function when it is called.

Number of Arguments

By default, a function must be called with the correct number of arguments. Meaning that if your function expects 2 arguments, you have to call the function with 2 arguments, not more, and not less.

If you try to call the function with 1 or 3 arguments, you will get an error:

Arbitrary Arguments, *args

If you do not know how many arguments that will be passed into your function, add a * before the parameter name in the function definition.

This way the function will receive a tuple of arguments, and can access the items accordingly:

Example

If the number of arguments is unknown, add a * before the parameter name:

Try it Yourself "

Arbitrary Arguments are often shortened to *args in Python documentations.

Keyword Arguments

You can also send arguments with the key = value syntax.

This way the order of the arguments does not matter.

The phrase Keyword Arguments are often shortened to kwargs in Python documentations.

Arbitrary Keyword Arguments, **kwargs

If you do not know how many keyword arguments that will be passed into your function, add two asterisk: ** before the parameter name in the function definition.

This way the function will receive a dictionary of arguments, and can access the items accordingly:

Example

If the number of keyword arguments is unknown, add a double ** before the parameter name:

Try it Yourself "

Arbitrary Kword Arguments are often shortened to **kwargs in Python documentations.

Default Parameter Value

The following example shows how to use a default parameter value.

If we call the function without argument, it uses the default value:

Example

Try it Yourself "

Passing a List as an Argument

You can send any data types of argument to a function (string, number, list, dictionary etc.), and it will be treated as the same data type inside the function.

E.g. if you send a List as an argument, it will still be a List when it reaches the function:

Example

fruits = ["apple", "banana", "cherry"]

my_function(fruits)

Try it Yourself "

Return Values

To let a function return a value, use the return statement:

Example

Try it Yourself "

The pass Statement

function definitions cannot be empty, but if you for some reason have a function definition with no content, put in the pass statement to avoid getting an error.

Positional-Only Arguments

You can specify that a function can have ONLY positional arguments, or ONLY keyword arguments.

To specify that a function can have only positional arguments, add , / after the arguments:

Without the , / you are actually allowed to use keyword arguments even if the function expects positional arguments:

But when adding the , / you will get an error if you try to send a keyword argument:

Keyword-Only Arguments

To specify that a function can have only keyword arguments, add *, before the arguments:

Without the *, you are allowed to use positionale arguments even if the function expects keyword arguments:

But when adding the *, / you will get an error if you try to send a positional argument:

Combine Positional-Only and Keyword-Only

You can combine the two argument types in the same function.

Any argument before the / , are positional-only, and any argument after the *, are keyword-only.

Recursion

Python also accepts function recursion, which means a defined function can call itself.

Recursion is a common mathematical and programming concept. It means that a function calls itself. This has the benefit of meaning that you can loop through data to reach a result.

The developer should be very careful with recursion as it can be quite easy to slip into writing a function which never terminates, or one that uses excess amounts of memory or processor power. However, when written correctly recursion can be a very efficient and mathematically-elegant approach to programming.

In this example, tri_recursion() is a function that we have defined to call itself ("recurse"). We use the k variable as the data, which decrements (-1) every time we recurse. The recursion ends when the condition is not greater than 0 (i.e. when it is 0).

To a new developer it can take some time to work out how exactly this works, best way to find out is by testing and modifying it.

Example

Recursion Example

Try it Yourself "

# data[].attributes.attachment_link.description
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

# data[].attributes.attachment_link.title
‎⁨كتب مهارات رقمية قسم متوسط 1444⁩

# data[].attributes.attachment_caption
السلام عليكم ورحمة الله وبركاته , بين أيديكن ملف وورد لمتابعة درجات الطالبات اليومي ,, منقول جزى الله من أعدهُ ونقلهُ خير الجزاء .. السجل مرتب وواضح ومرتب.

# data[].attributes.headline
* سجل المتابعة اليومي لطالبات الصف الثاني المتوسط ( منقول ) *

# data[].attributes.subject
* سجل المتابعة اليومي لطالبات الصف الثاني المتوسط ( منقول ) *

# data[].attributes.body
سجل متابعة يومي للطالبات ( منقول ),, أرجو منكن تقييمه لكي يتم اعتمادُه بارك الله فيكن جميعاً .

# data[].attributes.attachment_link.title
سجل المتابعة ثاني متوسط1000

# data[].attributes.headline
ورقه عمل تفاعليه لدرس اتخاذ القرار

# data[].attributes.subject
ورقه عمل تفاعليه لدرس اتخاذ القرار

# data[].attributes.body
أشواق العمار المتوسطه 176

# data[].attributes.attachment_link.provider_name
Wordwall - أنشئ دروسًا أفضل وبشكل أسرع

# data[].attributes.attachment_link.title
رتبي البرنامج بشكل صحيح

# data[].attributes.headline
اسئلة منوعة لكامل مقرر ثاني متوسط على شكل مطوية

# data[].attributes.subject
اسئلة منوعة لكامل مقرر ثاني متوسط على شكل مطوية

# data[].attributes.body
المعلمة: نورا اليوسف

# data[].attributes.attachment_link.title
مطوية أواق عمل 2م