Answer to Question #194485 in Python for desmond

Question #194485

1. Write a program that reads integers from the user and stores them in a list. Your program should continue reading values until the user enters 0. Then it should display all of the values entered by the user (except for the 0) in order from smallest to largest, with one value appearing on each line.


2. Two words are anagrams if they contain all of the same letters but in a different order. For example, “evil” and “live” are anagrams because each contains one ‘e’, one ‘i’, one 'l', and one ‘V'. Create a program that reads two strings from the user, determines whether or not they are anagrams.


3. Write a function that takes three numbers as parameters, and returns the median value of those parameters as its result


1
Expert's answer
2021-05-18T02:57:53-0400
#1
a = -1
l =[]
print('Enter the numbers, 0 for exit.')
while a != 0:
    a = int(input())
    if(a!=0):
        l.append(a)
l.sort()
print('Sorted list:')
for x in l: print(x)
#2
first = list(input('Enter the first word: '))
second = list(input('Enter the second word: '))
result = True
for a in first:
    try:
        second.remove(a)
    except ValueError:
        result = False
if len(second) > 0:
    result = False
print(result)
#3
import statistics
l =[]
for a in range(0, 3):
    l.append(int(input('Enter the number: ')))
print(statistics.median(l))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS