Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

P1. Implement two programs, in Racket and Python, to compute factorials. Submit a listing of your code, and the results. Remember: The factorial function, defined

image text in transcribed

P1. Implement two programs, in Racket and Python, to compute factorials. Submit a listing of your code, and the results. Remember: The factorial function, defined recursively by u 1, if n=0 and n.(n-1, otherwise. For example, 7' = 7-6-5-4-3-2-1 se enumerate the number of ways that n distinct objects can be permuted. Racket code: (not safe code- should really check for valid input, have error messages, etc.) (define (factorial n) (if (= n 0) (* n (factorial (-n 1))) Python code: (again, not safe code) def mainl n = eval(input("Enter a non-negative integer: ")) printl"Factorial of", n, "is", factorial(n) # Return the factorial for the specified number def factorial(n) if n== 0: # Base case return 1 se: return n * factorial(n-1) # Recursive call mainl) # Call the main function P2. Write a program, using Python, to determine the mean, median, and standard deviation of a list of numbers. In addition, count the number of duplicate numbers in the code and list any numbers that occur more than once, with the number of times the number occurs. Submit a listing of your code, and the results. List=[3, 6, 7, 2, 8, 9, 2, 3, 7, 4, 5, 9, 2, 1,6,9,6]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

Students also viewed these Databases questions