Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 4 - Selections - Programming Exercises - Page 123: 4.17

Answer

$Code:$

Work Step by Step

$Code:$ import random computer = random.randint(0, 3) user = int(input("Sciessor (0) , rock (1) , paper(2):")) print("the computer is ") if computer == 0: $ $ $ $ print("sciessor") elif computer == 1: $ $ $ $ print("rock") else: $ $ $ $ print("paper") print("You are ") if user == 0: $ $ $ $ print("sciessor") elif user == 1: $ $ $ $ print("rock") else: $ $ $ $ print("paper") if (computer == user): $ $ $ $ print("it is a draw") else: $ $ $ $ win = (user == 0 and computer == 2) or (user == 1 and computer == 0) or (user == 2 and computer == 1) $ $ $ $ $ $ $ $ if win: $ $ $ $ $ $ $ $ $ $ $ $ print("you won") $ $ $ $ $ $ $ $ else: $ $ $ $ $ $ $ $ $ $ $ $ print("you lose")
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.