• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 19 رای - 2.11 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: guessing game
حالت موضوعی
#1
درود

سورس کد بازی حدس عدد
اسکریپت را سریع نوشتم و ممکنه دارای مشکلاتی باشه اگر مشکلی پیدا کردید به بنده اطلاع بدید.

کد:
'code by Anarchy'
import random
import time
num=random.randint(1,50)
ntry=6
while 1:
    guess=int(input('guess a number:'))
    
    if guess==num:
        print('{} is correct you won'.format(num))
        time.sleep(3)
        exit()
    elif guess > num:
        ntry=ntry -1
        print(' to high')
    elif guess < num:
        ntry=ntry-1
        print('to low')
    if ntry<=0:
        print(ntry)
        print('you lose the correct number was:{}'.format(num))
        time.sleep(3)
        exit()
 
پاسخ
  


پرش به انجمن:


Browsing: 1 مهمان