code should be in python:
I need the user who's running the code to pick a game from 1 to 5 and the game they pick should work properly and let me know if any code errors can be fixed. I have made each game but i cant figure out how to make the user pick the game they want to try.
here's my code:
#game 1 you're supposed to input a sequence and the values are supposed to be shown how many times they are shown:
ip = input("Please enter your sequence:")
print("In the sequence we saw:")
for i in range(10):
k = 0
k = sum(int(c) == i for c in ip)
if k > 0:
print("{}: {} time(s)".format(i, k))
#game 2 the user is supoosed to enter 2 values as a range and it shows the possible 3 multipication in that range:
num1 = int(input("Enter Number 1:"))
num2 = int(input("Enter Number 2:"))
if(num1>num2):
for i in range(num2+1,num1):
if(i%3 == 0):
print(i)
if(num1<num2):
for i in range(num1+1,num2):
if(i%3 == 0):
print(i)
#game 3 is a
def largestWord(s):
s = sorted(s, key = len)
print("Result : ",s[-1],len(s[-1]))
if __name__ == "__main__":
s = input("Enter the string: ")
l = list(s.split(" "))
largestWord(l)
# game 4 is a function that receives a list as its only parameter. Inside the body of the function and removes all the duplicate items from the list:
def remove_duplicates (Data):
new_Data = []
for item in Data:
if (item not in new_Data):
new_Data.append(item)
return(new_Data)
print(remove_duplicates(["hey","swim","day","night","swim"]))
#game 5 function that receives a list of strings as its only parameter. Inside the body of the function and it finds the first palindromic word and returns it:
def palinCheck(lst):
for i in lst:
if i==i[::-1]:
return i
return ""
lst=["abc","hello","car","level","mom"]
print(palinCheck(lst))
Step by stepSolved in 2 steps
- ewqeqeqwe python pleasearrow_forwardIn various applications, you are often asked to compute the mean and standard deviation of data. The mean is simply the average of the numbers. The standard deviation is a statistic that tells you how tightly all the various data are clustered around the mean in a set of data. For example, what is the average age of the students in a class? How close are the ages? If all the students are the same age, the deviation is 0. Write a program that prompts the user to enter any number of values into a double array, and then calculates and displays the mean and standard deviations of these numbers using the following formulas: mean)? 2i +x2 + .. + xn i=1 i=1 mean = deviation = п - 1arrow_forwardPhyton Develop a program that reads a four-digit integer from the user and displays the sum of its digits. For example, if the user enters 3141 then your program should display 3+1+4+1=9.arrow_forward
- The owner of a venue for events needs software to keep track of reservations. The venue can handle two events in a day, one scheduled for the afternoon and another scheduled for the evening. Each event consists of the type (wedding, bar mitzvah, etc.), the date of the event, and whether or not the event will be held in the evening. A programmer writes the code given on the handout. Rewrite the above code so that It has all of the correct access modifiers for good encapsulation. Your code obeys the principle of encapsulation that obliges you to put each method in the proper class. Your code uses NO getters and NO additional classes or methods. You are welcome to modify any existing methods (including signatures and bodies) and/or move them between the existing classes. Your code DOES NOT modify any of the constructors. Important notes: You DO NOT have to write a main method. You DO NOT have to write tests. You DO NOT have to write Javadocs. You DO NOT have to write interfaces to…arrow_forwardPhyton Develop a program that reads a four-digit integer from the user and displays the sum of its digits. For example, if the user enters 3141 then your program should display 3+1+4+1=9.arrow_forwardPython Only answer: Alice is playing Air Hockey with Bob. The first person to earn seven points wins the match. Currently, Alice's score is A and Bob's score is B. Charlie is eagerly waiting for his turn. Help Charlie by calculating the minimum number of points that will be further scored in the match before it ends. Input Format The first line of input will contain an integer T - the number of test cases. The description of T test cases follows. The first and only line of each test case contains two space-separated integers A and B, as described in the problem statement. Output Format For each test case, output on a new line the minimum number of points that will be further scored in the match before it ends.arrow_forward
- PYTHON PROGRAMMING (practice review for final) (please see attached)arrow_forward1. Write a pyrhon program that prints out a classic hangman stick figure. The program should ask the user to enter a number from 1-6 and the corresponding hangman should be printed. The value the user inputs corresponds to the number of incorrect guesses in a real hangman game and so the completeness of the hangman will correspond to the number of ‘incorrect guesses’ inputted by the user (e.g., if the user enters 1, then only the head of the hangman will be printed; full example below). Example:Enter a number from 1-6: 1O Enter a number from 1-6: 2O|Enter a number from 1-6: 3O\||Enter a number from 1-6: 4O\|/|Enter a number from 1-6: 5O\|/|/Enter a number from 1-6: 6O\|/|/ \ 2. Modify your program from problem 1 so that the user input is checked to be a validsingle digit (1-6) before printing the corresponding hangman. If the input is not valid, theninstead of a hangman the following message should be printed “Invalid input: you must enter asingle number from 1-6.” Example:Enter a…arrow_forwardDo not send AI generated response to me. I need correct answer without any plagiarism otherwise I'll reduce rating for sure.arrow_forward
- Write code that iterates while userNum is less than 12. Each iteration: Put userNum to output. Then, put "/" to output. Then, assign userNum with userNum multiplied by 3.arrow_forwardTransient PopulationPopulations are affected by the birth and death rate, as well as the number of people who move in and out each year. The birth rate is the percentage increase of the population due to births and the death rate is the percentage decrease of the population due to deaths. Write a program that displays the size of a population for any number of years. The program should ask for the following data: The starting size of a population P The annual birth rate (as a percentage of the population expressed as a fraction in decimal form)B The annual death rate (as a percentage of the population expressed as a fraction in decimal form)D The average annual number of people who have arrived A The average annual number of people who have moved away M The number of years to display nYears Write a function that calculates the size of the population after a year. To calculate the new population after one year, this function should use the formulaN = P + BP - DP + A - Mwhere N is the…arrow_forwardIn various applications, you are often asked to compute the mean and standard deviation of data. The mean is simply the average of the numbers. The standard deviation is a statistic that tells you how tightly all the various data are clustered around the mean in a set of data. For example, what is the average age of the students in a class? How close are the ages? If all the students are the same age, the deviation is 0. Write a program that prompts the user to enter any number of values into a double array, and then calculates and displays the mean and standard deviations of these numbers using the following formulas: (z - mean) z+z3+ *** +zn deviation = mean = n-1 Required Methods You must write your program so that the following methods are defined/implemented and used (called): • /* Compute the deviation of double values */ public static double deviation (double[] x) • /* Compute the mean of an array of double values */ public static double mean (double[] x) Sample Run (user input…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education