Question

In: Computer Science

hi i need a code that will give me this output, For the multiply_list, the user...

hi i need a code that will give me this output,

For the multiply_list, the user will be asked to input the length of the list, then to input each element of the list.

For the repeat_tuple, the user is only asked to enter the repetition factor, but not the tuple. Your program should take the list created before and convert it to a tuple.

output expected: (**user input**)

******Create your List ******

Enter length of your list: 3

****** Start filling your List ******

Enter element 1: 2

Enter element 2: 3

Enter element 3: 4

Result of list multiplication: 24

*** Create a tuple and repeat it

Enter your repetition factor: 2

Repeated Tuple: (2, 3, 4, 2, 3, 4)

this is what i have so far:

print("\n********* Create Your List ********")


len_list = int(input("Enter length of your list: "))
print("\n********* Start filling your list ********")


if len_list > 0:
    element = int(input("Enter element {0}: ".format(len_list)))

Solutions

Expert Solution

print("***create your list***")
lenght_of_list = int(input("Enter Length of your list: "))
l = []
multiplication_result = 1
for i in range(lenght_of_list):
    l.append(int(input("Enter element "+str(i+1)+" ")))
    multiplication_result = multiplication_result*l[i]
print("Result of list multiplication : "+ str(multiplication_result))
def convert(list):
    return (*list,)
print("***create a tuple and repeat it ***")
tup = convert(l)
repetation_factor = int(input("Enter your repetation factor : "))
print(tup*repetation_factor)

Code:

print("***create your list***")
lenght_of_list = int(input("Enter Length of your list: "))
l = []
multiplication_result = 1
for i in range(lenght_of_list):
    l.append(int(input("Enter element "+str(i+1)+" ")))
    multiplication_result = multiplication_result*l[i]
print("Result of list multiplication : "+ str(multiplication_result))
def convert(list):
    return (*list,)
print("***create a tuple and repeat it ***")
tup = convert(l)
repetation_factor = int(input("Enter your repetation factor : "))
print(tup*repetation_factor)

Result:


Related Solutions

Hi, I have this code so far and need to modify it so that the output...
Hi, I have this code so far and need to modify it so that the output does not print something like 2x^0 but instead will just print 2. Currently it prints 2x^0. I also am having a problem with the output of Polynomial 1 - Polynomial 2. If both coefficient values for the polynomials are equal instead of Polynomial 1 - Polynomial 2 = 0 it outputs nothing. Just Polynomial 1 - Polynomial 2 = For example if I input...
Hi, I need the HTML5 code for the below. About Me **Would like to add a...
Hi, I need the HTML5 code for the below. About Me **Would like to add a image of a plane or something related to travel here. Mia Jo I am taking this class to earn my Computer programmer CL1. Things I Like to Do: Spend time with family Traveling People Watch Places I Want to Go or Have Visited: Dubai- December'18 Enjoyed shopping and the desert safari the most. Cuba- August '18 Enjoyed learning about the culture and history. China-...
java.. please dont change the format and give me an output sample! user need to input...
java.. please dont change the format and give me an output sample! user need to input k. public class Josephus {    /**    * All persons sit in a circle. When we go around the circle, initially starting    * from the first person, then the second person, then the third...    * we count 1,2,3,.., k-1. The next person, that is the k-th person is out.    * Then we restart the counting from the next person, go...
Hi, I need a Matlab code satisfies the following question. Output should be a graph similar...
Hi, I need a Matlab code satisfies the following question. Output should be a graph similar to a sine or cosine graph or similar to electrocardiograms (EKG/ECG) graph. Please I'd appreciate it. All love. Thanks :) In elementary quantum mechanics, the square well is used to model the behavior of a bound particle, in which one or more forces (external potentials, interaction with other particles, etc) prevent or restrict its ability to move about. We have seen in class that...
Hi there, I need mpx2100ap arduino code do I need an amplifier to make this work...
Hi there, I need mpx2100ap arduino code do I need an amplifier to make this work ?
I need to make this into a Java Code: Write a program that prompts the user...
I need to make this into a Java Code: Write a program that prompts the user for a double value representing a radius. You will use the radius to calculate: circleCircumference = 2πr circleArea = πr2 sphereArea = 4πr2 sphereVolume = 43πr3 You must use π as defined in the java.lang.Math class. Your prompt to the user to enter the number of days must be: Enter radius: Your output must be of the format: Circle Circumference = circleCircumference Circle Area...
c# code working but output not right, I need to output all numbers like : Prime...
c# code working but output not right, I need to output all numbers like : Prime factors of 4 are: 2 x 2 here is just 2 Prime factors of 7 are: 7 Prime factors of 30 are: 2 x 3 x 5 Prime factors of 40 are: 2 x 2 x 2 x 5 here is just 2,5 Prime factors of 50 are: 2 x 5 x 5 here is just 2,5 1) How I can fix it 2)I...
Hi i need a c++ program that can convert charactor into numbers pseodocode user input their...
Hi i need a c++ program that can convert charactor into numbers pseodocode user input their name for example john every single charactor should have a value so it return correct result eg: j=2, o=1, h=7,n=2 and display these numbers if you may need any question to ask me, i will be very happy to answer them. Thanks! example project close but not accurate #include #include #include #include #include #include #include #include #define INPUT_SIZE 8 using namespace std; // Function...
Hi i need a c++ program that can convert charactor into numbers pseodocode user input their...
Hi i need a c++ program that can convert charactor into numbers pseodocode user input their name for example john every single charactor should have a value so it return correct result eg: j=2, o=1, h=7,n=2 and display these numbers if you may need any question to ask me, i will be very happy to answer them. Thanks! example project close but not accurate #include<iostream> #include<string> #include<exception> #include <cstdlib> #include<stdio.h> #include<map> #include <cctype> #include<Windows.h> #define INPUT_SIZE 8 using namespace std;...
I need a java code Write a simple program to prompt the user for a number...
I need a java code Write a simple program to prompt the user for a number between 1 and 12 (inclusive) and print out the corresponding month. For example:   The 12th month is December. Use a java "switch" statement to convert from the number (1-12) to the month. Also use a "do while" loop and conditional checking to validate that the number entered is between 1 and 12 inclusive and if not, prompt the user again until getting the correct...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT