import random
def get_computer_choice():
return random.choice(['tosh', 'qaychi', 'qog\'oz'])
def determine_winner(user_choice, computer_choice):
if user_choice == computer_choice:
return 'Durrang!'
elif (user_choice == 'tosh' and computer_choice == 'qaychi') or \
(user_choice == 'qaychi' and computer_choice == 'qog\'oz') or \
(user_choice == 'qog\'oz' and computer_choice == 'tosh'):
return 'Foydalanuvchi G\'olib!'
else:
return 'Kompyuter G\'olib!'
def main():
user_score = 0
computer_score = 0
print("Tosh, qaychi, qog'oz o'yiniga xush kelibsiz!")
while True:
user_choice = input("Tosh, qaychi yoki qog'ozni tanlang (yoki chiqish uchun 'exit' deb yozing): ").lower()
if user_choice == 'exit':
break
if user_choice not in ['tosh', 'qaychi', 'qog\'oz']:
print("Noto'g'ri tanlov! Iltimos, 'tosh', 'qaychi' yoki 'qog'oz' deb tanlang.")
continue
computer_choice = get_computer_choice()
print(f"Kompyuter tanladi: {computer_choice}")
result = determine_winner(user_choice, computer_choice)
print(result)
if result == 'Foydalanuvchi G\'olib!':
user_score += 1
elif result == 'Kompyuter G\'olib!':
computer_score += 1
print(f"Foydalanuvchi: {user_score} | Kompyuter: {computer_score}")
print(f"O'yin tugadi! Foydalanuvchi: {user_score} | Kompyuter: {computer_score}")
if name == "main":
main()import random
def get_computer_choice():
return random.choice(['tosh', 'qaychi', 'qog\'oz'])
def determine_winner(user_choice, computer_choice):
if user_choice == computer_choice:
return 'Durrang!'
elif (user_choice == 'tosh' and computer_choice == 'qaychi') or \
(user_choice == 'qaychi' and computer_choice == 'qog\'oz') or \
(user_choice == 'qog\'oz' and computer_choice == 'tosh'):
return 'Foydalanuvchi G\'olib!'
else:
return 'Kompyuter G\'olib!'
def main():
user_score = 0
computer_score = 0
print("Tosh, qaychi, qog'oz o'yiniga xush kelibsiz!")
while True:
user_choice = input("Tosh, qaychi yoki qog'ozni tanlang (yoki chiqish uchun 'exit' deb yozing): ").lower()
if user_choice == 'exit':
break
if user_choice not in ['tosh', 'qaychi', 'qog\'oz']:
print("Noto'g'ri tanlov! Iltimos, 'tosh', 'qaychi' yoki 'qog'oz' deb tanlang.")
continue
computer_choice = get_computer_choice()
print(f"Kompyuter tanladi: {computer_choice}")
result = determine_winner(user_choice, computer_choice)
print(result)
if result == 'Foydalanuvchi G\'olib!':
user_score += 1
elif result == 'Kompyuter G\'olib!':
computer_score += 1
print(f"Foydalanuvchi: {user_score} | Kompyuter: {computer_score}")
print(f"O'yin tugadi! Foydalanuvchi: {user_score} | Kompyuter: {computer_score}")
if name == "main":
main()
#
@PythonUzbek kanali uchun maxsus
Pythonda Tosh qaychi qogʻoz oʻyini📈
@PythonUzbek⚡