Question

In: Computer Science

Write a program which accepts a sequence of comma-separated numbers from console and generate a list...

Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. Suppose the following input is supplied to the program: 34, 67, 55, 33, 12, 98. Then, the output should be: ['34', '67', '55', '33', '12', '98'] and ('34',67', '55', '33', '12', '98'). Input can be comma separated in one line.

Solutions

Expert Solution

sequence = input("Enter Comma Separated numbers : ")

# removing spaces in sequence
sequence = sequence.replace(" ","")

# splitting comma separated values
sequence = sequence.split(",")

# converting sequence to list
n1 = list(sequence)

# converting sequence to tuple
n2 = tuple(sequence)

# printing list and tuple
print("List  : ",n1)

print("Tuple : ",n2)

Code

Output


Related Solutions

Write a program which accepts a sequence of comma-separated numbers from console and generate a list...
Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. Suppose the following input is supplied to the program: 34, 67, 55, 33, 12, 98. Then, the output should be: ['34', '67', '55', '33', '12', '98'] and ('34',67', '55', '33', '12', '98').
Write a program in python language, which accepts 2 numbers and a + sign (for addition)...
Write a program in python language, which accepts 2 numbers and a + sign (for addition) A sign - (for subtraction) A sign * (for multiplication), / (for division) Then calculate and to display the result of the operation he chose with the two numbers. Displaying the appropriate message
specifications for Tasks: 1. Write a program which accepts a list of integers which may contain...
specifications for Tasks: 1. Write a program which accepts a list of integers which may contain duplicated integers, and which outputs the input list as a sorted list in ascending order without duplication You can use either Ruby, C, C++, C# or Java to implement your program (referred to as P). 2. Design a test suite of 10 test cases (referred to as TC). Each test case has not more than 20 integers. 3. Test P against TC to make...
Write a MIPS program that will ask the user to enter two numbers at the console...
Write a MIPS program that will ask the user to enter two numbers at the console and pass the values to a function that does multiplication
2-Find the critical numbers of the function. (Enter your answers as a comma-separated list. Use n...
2-Find the critical numbers of the function. (Enter your answers as a comma-separated list. Use n to denote any arbitrary integer values. If an answer does not exist, enter DNE.) f(θ) = 6 cos(θ) + 3 sin2(θ) 3- Consider the following. f(x) = x5 − x3 + 9,    −1 ≤ x ≤ 1 (a) Use a graph to find the absolute maximum and minimum values of the function to two decimal places. maximum     minimum (b) Use calculus to find the exact...
Write RTL code to design a sequence generator which will generate the sequence : 0,0,1,0,1,1 and...
Write RTL code to design a sequence generator which will generate the sequence : 0,0,1,0,1,1 and repeat .  (FSM shouldn't be used in RTL) 
In a program, write a function that accepts two arguments: a list, and a number n....
In a program, write a function that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all of the numbers in the list that are greater than the number n. The program should ask for a list of numbers from the user as well as a value (a, b, c)--> inputs from user. After that, each number in that list should be compared to that value (a or b or...
Write a test program that prompts the user to enter a sequence of numbers ending with...
Write a test program that prompts the user to enter a sequence of numbers ending with 0, and invokes this method to return the largest number in the input. Use inheritance and polymorphism approach. in java please
In python, write a function, called ThreeSum, that accepts a list of non-negative numbers as input,...
In python, write a function, called ThreeSum, that accepts a list of non-negative numbers as input, and returns the highest sum of three neighboring elements in it. Write a main method that initializes the following five lists, gets the ThreeSum result for all of them using the above function, and prints the result to the screen. Example of the output: List 1: [4,5,4,5] , Three sum = 14 List 2: [7] , Three sum = 7 List 3: [ ]...
Write a Java program to generate random numbers in the following range a. 1 <=n <=...
Write a Java program to generate random numbers in the following range a. 1 <=n <= 3 b. 1 <= n <= 200 c. 0 <= n <= 9 d. 1000 <= n <= 2112 e. -1 <= n <= 5 JAVA PROGRAMMING
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT