IN PYTHON
Write a program that reads a list of integers in the range (0 – 49) and prints out the numbers that does not repeat twice.
The first input of the program is the number of integers contained in this list, followed by the integers contained in the list. Print the numbers in in ascending order.
Case 1:
INPUT: 5 2 2 3 3 1
OUTPUT:1
Case 2:
INPUT:6 1 2 1 2 2 2
OUTPUT:2
Case 3:
INPUT:4 3 2 1 2
OUTPUT: 1 3
3
4
3 2 1 2
1
3
Answer:
Explanation:
First number of elements are taken as input.
Then using a loop, all the numbers are appended to a list.
Then using another loop on the sorted list, if the count of element is 1, only then it is printed out.
feel free to comment if you need any help!
Code:
n = int(input())
l=[]
for i in range(n):
num = int(input())
l.append(num)
for element in sorted(l):
if(l.count(element)==1):
print(element,end= ' ')
Output:
PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
PLEASE COMMENT IF YOU NEED ANY HELP!
Write a program that reads a list of integers in the range (0 – 49) and prints out the numbers that does not repeat twice
Write a function in PYTHON that reads a sequence of numbers ended by 0 and prints “Sorted” if the numbers were input in increasing or decreasing order, otherwise the program must print “Not sorted” (Do not calculate 0) Sample Input 4 3 -1 -5 0 Sample Output Sorted
In C++: Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The list is preceded by an integer indicating how many numbers are in the list. If the input is: 5 10 5 3 21 2, the output is: 2 3 To achieve the above, first read the integers into a vector.
C programming! Write a program that reads integers until 0 and prints the sum of values on odd positions minus the sum of values on even positions. Let ?1, ?2, … , ??, 0 be the input sequence. Then the program prints the value of ?1 − ?2 + ?3 − ?4 + ⋯ ??. The input is a sequence of integers that always contains at least 0 and the output will be a single number. For example, for input...
JAVA. Write a program that reads in a series of positive integers and prints out the maximum value entered. The user will indicate they are finished entering numbers by entering zero or a negative integer.
1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...
Write a C program that reads a sequence of numbers and display a message 1. The numbers a re red from the standard input. 2. The first number is the length of the sequence (n) followed by n numbers. 3. If n is 0 or negative, the program displays the message "Error_1" followed 4. If the length is shorter than n, it displays "Error_2" followed by a new line 5. The program inspects the list and display one of the...
6.2 - Write a program that reads numbers and adds them to a list if they aren't already contained in the list. When the list contains ten numbers, the program displays the contents and quits. Use Python 3 Please. Comments in code if you can
Write a program that reads a list of integers ending with a negative, and that then outputs that list in reverse. After the negative that ends the list, a character indicates what character should separate the output integers. If the input is: 3 5 2 - 1 * the output is: 2*5*3 LAB ACTIVITY 7.16.1: LAB: Reverse a list, with separating characters 2 / 10 main.cpp Load default template... 6 7 8 int numbers [100],i=0, num, size; char character; cin>>num;...
Write a program file_max.c that reads a set of integer numbers from a file and prints out the maximum number to standard output. The name of the input file should be specified as a command line argument.
1. Write a python program that reads a file and prints the letters in increasing order of frequency. Your program should convert entire input to lower case and only counts letters a-z. Special characters or spaces should not be counted. Each letter and it's occurrences should be listed on a separate line. 2. Test and verify your program and it's output. ---Please provide a code and a screenshot of the code and output. Thank you. ----