1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anika [276]
2 years ago
8

(Print distinct numbers) Write a program that reads in integers separated by a space in one line and displays distinct numbers i

n their input order and separated by exactly one space (i.e., if a number appears multiple times, it is displayed only once). Hint: Read all the numbers and store them in list1. Create a new list list2. Add a number in list1 to list2. If the number is already in the list, ignore it.
Computers and Technology
1 answer:
irina [24]2 years ago
6 0

Answer:

Following are the program to the given question:

num = input("Enter numbers: ")#defining a variable num for input value  

list1 = num.split()#defining a list1 that adds value in list1  

list2 = []#defining an empty list list2

for j in range(len(list1)):#defining a for loop that checks the list value in range  

   if not list1[j] in list2:# use if block that checks multiple value

       list2.append(list1[j])#add value in list2

print("The distinct numbers are: ")#print message

for j in range(len(list2)):#defining for loop for print list value

   print(list2[j])#print list value

Output:

Enter numbers: 1 22 55 7 22 1 1 2 3

The distinct numbers are:  

1

22

55

7

2

3

Explanation:

In the above-code, a "num" variable is defined, that takes inputs from the console screen, and in the next step, "list1 and list2" is defined. In the "list1" it adds num variable value a into the list.

In the next step, a for loop is defined that checks the list value in range , and define an if block, that checks multiple value and add value into the list2, and in the next step, the for loop is defined that prints the list2 values.    

You might be interested in
When parking uphill on a street with no curb, how should your front wheels be positioned? A. Turned to the left (toward the stre
Shkiper50 [21]
The answer is B. It matters which way you park your car . Your car should also be parallel to the carb but with the wheels inward to the right
8 0
3 years ago
Read 2 more answers
is skill in using productivity software, such as word processors, spreadsheets, database management systems, and presentation so
Digiron [165]

Answer:

It is general knowledge

Explanation:

What you covered is general knowledge and the entrance to computer science.

4 0
3 years ago
What is the difference between ARM and INTEL Chip?
tia_tia [17]
With the ever-present rumor of ARM MacBooks<span> gaining renewed energy, it’s time to get an understanding of the technical differences between ARM processors and the more common x86 processors made by </span>Intel<span> and AMD.</span>
8 0
3 years ago
Does my computer have virus?
vivado [14]

Answer:

does your toothpaste have salt?

6 0
2 years ago
Read 2 more answers
In Full Screen Reading View, which area is reduced?
REY [17]

Go to options .

  • Suppose you are reading a document .
  • You want to read in full screen .
  • Hence the Go-to bar will be reduced .
6 0
3 years ago
Other questions:
  • Assuming arrayName is the name of an array and identifier is a name of a variable that has the same data type as the array eleme
    6·1 answer
  • Which Computer career field enables you to create and design interactive multimedia products and service
    5·2 answers
  • Define a function CoordTransform() that transforms the function's first two input parameters xVal and yVal into two output param
    11·1 answer
  • Suppose that you created an robot that was so advanced it could act independently in very complex situations. It made its own de
    9·1 answer
  • 1.where should the name of the website or company logo appear on a website
    5·2 answers
  • What is the term used for describing the judgement or common sense part of problem solving​
    11·1 answer
  • A device that protects electronic equipment from an increase in power, but not a decrease or outage is a ___.
    12·1 answer
  • Part 2: a) Write VHDL code for a top module that invokes necessary components to display the four decimal digits on four seven-s
    5·1 answer
  • Which option is the default when creating appointments and meetings in a user’s own calendar as it relates to Free/Busy informat
    8·1 answer
  • Technology changes rapidly. Do you think the development of new technology will slow down at some point? At some point will cons
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!