Question: QUESTION 2) python programming, using python 3. No if and else statements/loops allowed for these questions. A) In this question you will write a function

QUESTION 2)

python programming, using python 3. No if and else statements/loops allowed for these questions.

A) In this question you will write a function that determines the result of a rock, paper, scissors game given choices of player 1 and player 2. In particular, write a function rps_winner() that prompts the user for choice of player 1 and then choice of player 2, and then it displays the result for player 1 as indicated in the examples given in Section 2. You may assume that the user will only enter words: rock, paper or scissors in lower case. Recall that paper beats rock, that rock beats scissors and that scissors beat paper. If both players make the same choice, we have a draw.

B) Write a function safe(n) that takes a non-negative integer n as input where n has at most 2 digits. The function determines if n is a safe number. A number is not safe if it contains a 9 as a digit, or if it can be divided by 9. The function should test if n is safe and return True if n is safe and False otherwise.

#testing question 2a)

rps_winner() What choice did player 1 make? Type one of the following options: rock, paper, scissors: rock What choice did player 2 make? Type one of the following options: rock, paper, scissors: paper Player 1 wins. That is False It is a tie. That is not True >>> rps_winner() What choice did player 1 make? Type one of the following options: rock, paper, scissors: paper What choice did player 2 make? Type one of the following options: rock, paper, scissors: rock Player 1 wins. That is True It is a tie. That is not True >>> rps_winner() What choice did player 1 make? Type one of the following options: rock, paper, scissors: scissors What choice did player 2 make? Type one of the following options: rock, paper, scissors: paper Player 1 wins. That is True It is a tie. That is not True >>> rps_winner() What choice did player 1 make? Type one of the following options: rock, paper, scissors: paper What choice did player 2 make? Type one of the following options: rock, paper, scissors: paper Player 1 wins. That is False It is a tie. That is not False >>>

# testing Question 2b) >>>

>>> safe(93)

False >>> safe(82)

True >>> safe(29)

False >>> safe(36)

False >>> safe(9)

False >>> safe(7)

True >>>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!