كود عداد ناسا
import time
print("counting...")
def countdown (n) :
while n > 0 :
print (n)
time.sleep(1)
n -=1
if n== 0:
print("launched !")
countdown(10)
كود عداد ناسا
import time
print("counting...")
def countdown (n) :
while n > 0 :
print (n)
time.sleep(1)
n -=1
if n== 0:
print("launched !")
countdown(10)
print('Counting ...')
count = 10
while count >=0:
print(count)
count = count - 1
print('launched !')
عمل جيد يا محمد
لاحظ أن التحقق من قيمة n == 0 سيتم تشغيله 10 مرات (لأنها داخل الحلقة)، لكن الطباعة تتم مرة واحدة فقط داخل الشرط if:
if n== 0:
print("launched !")
هل بإمكانك تحسينها وجعلها تنفذ مرة واحدة فقط وتطبع مرة واحدة فقط؟
عمل رائع يا ناصر
قمت بتنسيق الأكواد خاصتك، فضلا اطلع على طريقة تنسيق الأكواد في هذا الموضوع:
count =10
print('counting ....')
while count>=0:
print(count)
count=count-1
print('lanched !')
أهلا بك معنا يا حسن
عمل رائع
قمت بتنسيق الأكواد خاصتك، فضلا اطلع على طريقة تنسيق الأكواد في هذا الموضوع:
print("counting...")
counting = 10
while counting >= 1:
print(counting)
counting = counting - 1
print("launched !")
عمل جميل يا optimistic
شكرا لك صديقى
السلام عليكم
حل العداد التنازلي لناسا كالتالي:
print("counting...")
count = 10
while count >= 0:
print (count)
count -= 1
print("launched !")
عمل جميل يا Pity
اجابتي…
print("counting...")
x = 10
while x <= 10 and x >= 0:
print(x)
x = x - 1
print("launched !")
عمل جميل يا hichambq
print(‘counting…’)
count = 10
while (count > -1):
print(count)
count -= 1
print(‘launched !’)
ملحوظة ال indents مسافات السطر الرابع والخامس لم تظهر عند نسخ الكود هنا لا اعرف السبب
عمل جميل يا hedraatia2020
لو ممكن تقوم بتنسيق الكود و ذلك باتباع الخطوات حسب هذا الرابط
currentNum = 10;
print("counting..")
while currentNum >= 0:
print(currentNum)
currentNum -= 1;
print("launched!")
عمل رائع يا محمد
print 'counting...'
count = 10
while count >= 0:
print(count)
count-=1
print 'launched !'
# counting...
# 10
# 9
# 8
# 7
# 6
# 5
# 4
# 3
# 2
# 1
# 0
# launched !
عمل رائع يا معتز
لا تنسى مراعاة المسافات (indents) عند نسخ الأكواد
تم التعديل