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.
In this exercise, you’ll write a program that accepts a person’s birth date from the console...
In this exercise, you’ll write a program that accepts a person’s birth date from the console and displays the person’s age in years. To make that easier to do, we’ll give you a class that contains the code for accepting the birth date. The console output for the program should look something like this: f Welcome to the age calculator. j Enter the month you were born (1 to 12) : 5 Enter the day of the month you were...
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
In C++, Write a program that accepts exactly ten (10) integer numbers from the user. When...
In C++, Write a program that accepts exactly ten (10) integer numbers from the user. When the user is done inputting these numbers, the program prints back: (i) the sum of the 10 numbers, (ii) the minimum value from the 10 numbers, and (iii) the maximum value from the 10 numbers.
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT