Create a python program that will: prompt a user for a command Command get_data Level 1: Take one of...

60.1K

Verified Solution

Question

Programming

Create a python program that will:

  • prompt a user for a command

  • Command

    • get_data

  • Level 1: Take one of the commands

    • my_max

    • my_min

    • my_range

    • my_sum

    • mean

    • median

    • mode
    • fib
    • factorize
    • prime

Requirements:

  • Your commands should be case-insensitive

  • You should use python lists to store data

  • You should NOT use built-in python math functions, ormath libraries to compute these values

Tips:

  • Write one function that will convert a string withcomma-separated numbers into a python list with the numbers. Youcan use this in multiple other functions.

  • Don't name any of your functions \"min\", \"max\", or\"range\" or \"sum\". These are built-in functions.




Details

Load command details

  • Get_data: prompts users for a list of numbers, separatedby commas

    • (please also print the list, for testing)

Level 1 details (these functions work with the loadeddata list)

  • my_max

  • my_min

  • my_range: Computes the range (difference of greatestvalue and least value)

  • my_sum

  • mean: Computes and prints the arithmetic mean(average)

Level 2

  • median: show the median (middle value, or average of twomiddle values)

  • mode: show the mode, or modes

Level 3 details (these functions should use the firstnumber in the data list)

  • prime: determine if a number is prime

  • factorize: get the prime factors of anumber

  • fib: get the nth number in the fibonaccisequence

Here is my code so far:

#hehe my sum and stuff
f = open(\"input.txt\",'r')
def input(prompt=''):
print(prompt, end='')
return f.readline().strip()   

#get data
def get_data():
pass

line = input().strip().split(',')
  
nums=[]
for n in line:
nums.append(float(n))

  
return nums
  
#get sum
def my_sum(data):
  
s=0
for n in data:
s += n
return s
  
pass

#get max
def my_max(data):
  
m=0
for n in data:
m >= n
return m

pass

#get min
def my_min(data):
  
i=0
for n in data:
i < n
return i

pass

#get range
def my_range(data):
r=0
for n in data:
m - i
return r

pass

#get mean
def mean(data):
e=0
for n in data:
????????

#get median
def median(data):
d=0
for n in data:
??????
  
#get mode
def mode(data):
o=0
for n in data:
???
  
#get prime
def prime(data):
p=0
for n in data:
???

#get factorization
def factorization(data):
f=0
for n in data:
????
  
#get fib
def fib(data):
b=0
for n in data:
??
#run it
def run_cli():
  
while(1):
cmd = input()
  
if cmd=='exit':
break
  
elif cmd=='get_data':
data = get_data()
print(data)
  
  
elif cmd=='my_sum':
s = my_sum(data)
print(s)
  
elif cmd=='my_max':
m = my_max(data)
print(m)
  
elif cmd=='my_min':
i = my_min(data)
print(i)
  
elif cmd=='my_range':
r = my_range(data)
print(r)
  
elif cmd=='mean':
e = mean(data)
print(e)
  
elif cmd=='median':
d = median(data)
print(d)
  
elif cmd=='mode':
o = mode(data)
print(o)
  
elif cmd=='prime':
p = prime(data)
print(p)
  
elif cmd=='factorization':
f = factorization(data)
print(f)
  
elif cmd=='fib':
b = fib(data)
print(b)
  
pass

#ha ahsbas
def main():
run_cli()
  
main()

Answer & Explanation Solved by verified expert
3.8 Ratings (358 Votes)
Heres the missing functions please do as needed and if you need any further help you can always reach out to me in comments f openinputtxtr def inputprompt printprompt end return freadlinestrip get data def getdata pass line inputstripsplit nums for n in line numsappendfloatn return nums get sum def mysumdata s0 for n in data s n    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students