Write a program that simulates a card game. The user inputs a card number from 1 to 13 repeatedly. If the input card number is 13 or negative, the user does not get another card and the program displays a message such as ‘Terminating execution’. For all other valid cards, the card number can be displayed back.
Answers
Answer:
card = (int(input("enter card from 1-13:", )
if card > 13 or < 0:
else:
print ("Terminating Execution")
Answer:
while True:
card_number = int(input("Enter a card number from 1 to 13 (or -1 to quit): "))
if card_number == 13 or card_number < 0:
print("Terminating execution.")
break
else:
print("You have drawn card number:", card_number)
Explanation:
This program uses a while loop to repeatedly prompt the user to enter a card number. Inside the loop, the program checks the value of the card number. If it is 13 or negative, the loop is broken and the program displays a message "Terminating execution.". If the card number is a valid input (1 to 12) the program will display the input number.
More question and answers:
https://brainly.in/question/54812489
https://brainly.in/question/49639138
#SPJ3