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]
3 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]3 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
You are working from home and want to discuss a controversial topic. It is important you see the facial expressions of your cowo
k0ka [10]

Answer:

Maintaing Focus and keeping the meeting comfortable and moving.

Explanation:

5 0
3 years ago
Read 2 more answers
Differentiate between symmetric and asymmetric encryption
Shalnov [3]

Answer:

While symmetric encryption uses a single shared key to encrypt and decrypt data, asymmetric uses two separate keys

8 0
2 years ago
Read 2 more answers
Which of the following application delivery methods requires Internet access?
morpeh [17]

Answer:Cloud hosted

Explanation:

3 0
3 years ago
In 2-3 sentences, describe a case where circuit-switching is better than packet-switching?
cupoosta [38]
Because electricity powers everything , electricity can do anything
6 0
3 years ago
Because of their reasonable cost and print quality ___ printers are used in homes and schools
serious [3.7K]

'INK-JET'
because of their reasonable cost and print quality ___ printers are used in homes and schools

7 0
4 years ago
Other questions:
  • Hen pointing to a tool on the ribbon, a ______ appears, displaying information about the tool.
    7·1 answer
  • A/An _______ occupies a continuous block of multiple pieces of data.
    6·2 answers
  • we studied FIFO, Priority, Round Robin (RR), and Weighted Fair Queueing (WFQ) packet scheduling disciplines. Which of these queu
    12·1 answer
  • The seven basic internal components found in a computer tower
    9·1 answer
  • Imagine you are building an ATM system; list at least 6 application domains for the system. That is, in which context is the sys
    13·1 answer
  • PLEASE HELP 98 POINTS!!!!!!!!!!!!!!!!!!
    12·2 answers
  • System A has two processors. Program X takes 50 seconds to execute on one of the processors. Program Y takes 50 seconds to execu
    8·1 answer
  • Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. T
    11·1 answer
  • Blank Are input instructions you give to a computer
    13·1 answer
  • Identify the parts of it, Give at least three web browser that you usually used to visit a website.​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!