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

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...
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...
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...
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...
I need the output of the code like this in java First we create a new...
I need the output of the code like this in java First we create a new building and display the result: This building has no apartments. Press enter to continue......................... Now we add some apartments to the building and display the result: This building has the following apartments: Unit 1 3 Bedroom Rent $450 per month Currently unavailable Unit 2 2 Bedroom Rent $400 per month Currently available Unit 3 4 Bedroom Rent $1000 per month Currently unavailable Unit 4...
Here is my java code. It works and has the correct output, but I need to...
Here is my java code. It works and has the correct output, but I need to add a file and I am not sure how. I cannot use the FileNotFoundException. Please help! import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Exercise { public static void main(String[] args) { Scanner input=new Scanner(System.in); int[] WordsCharsLetters = {0,0,0}; while(input.hasNext()) { String sentence=input.nextLine(); if(sentence!=null&&sentence.length()>0){ WordsCharsLetters[0] += calculateAndPrintChars(sentence)[0]; WordsCharsLetters[1] += calculateAndPrintChars(sentence)[1]; WordsCharsLetters[2] += calculateAndPrintChars(sentence)[2]; } else break; } input.close(); System.out.println("Words: " + WordsCharsLetters[0]); System.out.println("Characters: "...
I need to fix this code, and could you please tell me what was the problem...
I need to fix this code, and could you please tell me what was the problem options 1 and 9 don't work #include <stdio.h> #include <time.h> #include <stdlib.h> // generate a random integer between lower and upper values int GenerateRandomInt(int lower, int upper){     int num =(rand()% (upper - lower+1))+lower;     return num; } // use random numbers to set the values of the matrix void InitializeMatrix(int row, int column, int dimension, int mat[][dimension]){     for(int i =0; i<row; i++){...
I need a speech to give me a girlfriend. I want to tell her how much...
I need a speech to give me a girlfriend. I want to tell her how much I love her and how much she means to me. I want to tell her that she is the only thing I think of from morning till night. Her name is Angie. she is the most beautiful girl I have ever met and I need something like a paragraph to show how much I love her. I want it so sweet and loving that...
I need for you to look at a couple of things and give me some guidance....
I need for you to look at a couple of things and give me some guidance. The workers in the assembly department are paid three different wages. Senior Assemblers, who have been with the company for more than five years, are paid $15 per hour. Experienced Assemblers, who have been with the company between one and five years, are paid $12 per hour. Novice Assemblers, who have been with the company less than one year, are paid $10 per hour....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT