مشاركة حلول: معالجة العديد من طلبات التقديم scholarships

عمل رائع (كذلك مع المهام السابقة)… تابع التقدم :wink:

def apply():
    age = input()
    age = int(age)

    if age < 18:
        print('You are too young')
    elif age <= 22:
        print('Welcome to Egypt scholarship program')
    else:
        print('You are too old')
    
apply()
apply()
apply()
apply()
apply()
def apply():
    try:
        age = input()
        age = int(age)

        if age < 18:
            print('You are too young')
        elif age <= 22:
            print('Welcome to Egypt scholarship program')
        else:
            print('You are too old')
    except Value Error:
        apply()
    
for m in range(0,1000):
    apply()
2 Likes

شرح جميل , وهذا الرابط :point_down:
https://www.w3schools.com/python/python_try_except.asp

2 Likes

عمل جميل جدا اخي
ملاحظة بسيطة
لاحظ ان في حالة ادخال قيمة غير عددية مثلا حرف، البرنامج لا يعمل و هذا بسبب خطأ في كتابة except ValueError انت كتبتها هكذا except Value Error هناك مسافة بين Value و Error .
بالتوفيق

2 Likes

شكرا

هذه ابسط الاخطاء :sweat_smile:

2 Likes

معلجة العديد من طلبات التقديم

def apply():
    age = int(input('Enter your age '))
    if age >=22:
        print('You are too old')
    elif age > 18:   
        print('Welcome to Egypt scholarship program')
    else:
        print('You are too young')
count=0
while count <= 4:
    apply()  
    count += 1
    


2 Likes

عمل جميل جدا queen1.

1 Like

السلام عليكم اعتذر عن التأخر:bouquet:

def apply():
    age=input('how old are you')
    age=int(age)
    if age>22:
       print('you are too old')
    elif age<18:
         print('you are too young')
    else:
         print('welcome to Algéria scholarship program')
#nbr_candidat=input('Enter the number of candidates')
#nbr_candidat=int(nbr_candidat)
nbr_candidat=1
while nbr_candidat<=1000:
      apply()
      nbr_candidat=nbr_candidat+1
2 Likes

عمل رائع يا امال.

2 Likes

شكرا جزيلا استاذ اسماعيل

2 Likes
def apply () :
    age = input('Enter your age: ')
    age = int(age)
    if age < 18 :
        print('you are too young')
    elif age <= 22 :
        print('welcome to Egypt scolarship program')
    else:
        print('you are too old')
count = 0
while count < 1000:
    apply()
    count +=1
3 Likes

عمل رائع arijtrabelsi.
بالتوفيق

2 Likes

main.py

# Fadi Rustom
def apply():
    try:
        # When things are correct, execute the program
        age =int(input("Enter your age:" ))
        if age < 18:
         print("You are too young")
        elif age > 22:
         print("You are too old")
        else :
          print("Welcome to Egypt scholarship program")
    except ValueError:
        # When an error occurs, enter a number to call the child
        print("Enter your age in numbers ")
        apply()

# Start of the program
# Choose a value from 0 to 1000 at random, and repeat the loop
for i in range(0,1000):
    apply()
2 Likes

عمل رائع يا FadiRustom.

1 Like

استدعاء الداله 5 مرات

def apply () :
    Age = input()
    Age = int(Age)
    if Age < 18 :
        print ("you are young")
    elif Age > 25 :
        print ("you are old")
    elif Age > 18 & Age < 25 :
        print ("welcome in Egypt")
    else :
        print  ("Not Avaluable")
apply ()
apply ()
apply ()
apply ()
apply ()
1 Like

زياده 1000

def apply () : 
    Age = input() 
    Age = int(Age) 
    if Age < 18 :
        print ("you are young")
    elif Age > 25 : 
        print ("you are old") 
    elif Age > 18 & Age < 25 : 
        print ("welcome in Egypt") 
    else : print ("Not Avaluable") 
n = 0
while n < 1000 :
    apply ()
n+=1
1 Like

عمل رائع، أميرة :+1:

يوجد مشكلة في هذه الحلقة:

while n < 1000 :
    apply ()
n+=1

هل بإمكانك معرفتها؟

  • تلميح: جربي تغيير الرقم 1000 إلى 3

اضف 4 مسافات اول السطر قبل النص المنسق

def apply():
    try:
        age = input("Enter your age:")
        age = int(age)
        if age < 18:
            print("You are too young")
        elif age <= 22:
            print("Welcome to Jordan scholarship program")
        else:
            print("You are too old")
    except ValueError:
        apply()
apply()
apply()
apply()
apply()
apply()
1 Like

عمل ممتاز كالعادة :ok_hand:

بدل اضافة اربع مسافات استعمل الطريقة الاخيرة باضافة ``` قبل وبعد الكود

def apply():
age = input()
age = int(age)

if age < 18:
    print('you are too young')
elif age > 22:
    print('you are too old')
else:
    print('welcome to egypt scolarship program')        

count = 0
while count <= 1000:
apply()
count += 1

1 Like