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').

Solutions

Expert Solution

CODE: Python Programming Language

# Takihng comma separated values from the console
input_values = input()
# Generate list
lst = input_values.split(",")
# Generate tuple
tup = tuple(lst)
# Printing list
print(lst)
# Printing tuple
print(tup)

====================================================================

SCREENSHOT OF THE CODE:

====================================================================

OUTPUT:

Thank you. Please ask me if you have any doubt.


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'). Input can be comma separated in one line.
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 program in Java which performs the sort operation. The main method accepts ten numbers...
Write a program in Java which performs the sort operation. The main method accepts ten numbers in an array and passes that to the method sort. The method sort accepts and sorts the numbers in ascending and descending order. The method display shows the result. You can use integers or floating point numbers.
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 python program that asks the user to enter a string containing numbers separated by...
Write a python program that asks the user to enter a string containing numbers separated by commas, e.g., s = '1.23,2.4,3.123', Your program should then calculate and print the sum of the numbers entered. Hint: you need to iterate over the string searching for the commas, i.e. their index. The first number is obtained by slicing between the start of the string and the index of the first comma. The second number is between the last comma and the next...
(JAVA) Create a program that takes in 15 numbers in sorted order from the console and...
(JAVA) Create a program that takes in 15 numbers in sorted order from the console and stores them in a 1D array of size 15. Next, prompt the user for a number to search for in the array (target). Then, print the array. Next, search the array using a linear search – printing out each of the indices (or “indexes”) that are being examined until the algorithm either finds the target or doesn’t. Then, do the same thing for a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT