Implement a function prime that takes a positive integer


Problem

Question I: Rock, Paper, Scissors is a two-player game in which each player chooses one of three items. If both players choose the same item, the game is tied. Otherwise, the rule that determines the winner is:

i. Rock beats Scissors.
ii. Scissors beat Paper.
iii. Paper beats Rock.

Implement function crsp() that simulates a game between a computer and a player. The function randomly selects the number of rounds to play (between 1 and 10 inclusive) then ask the user to input 'R', "S' or 'P', and randomly selects 'R', 'S' or 'P' for computer and gives 1 point to the winner in each round. If it is a tie no one gets a point. At the end of each round, it states who won (or states it was a tie) and the current score. After all the rounds are played the function announces the winner ("The computer won" or "The player won").

Question II: Implement a function prime() that takes a positive integer as input and returns True if it is a prime number and False otherwise.

Question III: Implement a function evenrow() that takes a two-dimensional list of integers and returns true if each row of the table sums up to an even number and False otherwise (i.e., some row sums to an odd number).

>>l=[[1,2,3],[4,5,6],[7,8,9],[1,5,6]]
>>l1=[1,2,3,4],[2,6,7,9],[3,5,7,9]]
>>evenrow(l)
False
>>evenrow(l1)
True

Question IV: Implement a function names() that takes no input arguments and repeatedly asks the user to enter the first name of a student in a class. When the user enters the empty string, the function should print for every name the number of students with that name.

>>> names()
Enter next name: Valerie
Enter next name: Bob
Enter next name: Valerie
Enter next name: Amelia
Enter next name: Bob
Enter next name:
There is 1 student named Amelia
There are 2 students named Bob
There are 2 students named Valerie.

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Implement a function prime that takes a positive integer
Reference No:- TGS03249170

Expected delivery within 24 Hours