View the step-by-step solution to:

Read the instructions below carefully. The instructions must be followed. function design, function calls, branching (that is, if statements),...

This assignment can only be done using python programming language please and is due in 24 hours. Please I need accurate answers. It is worth a lot. Attached is a document of the assignment and this also a link for a  video for  clarification  of part 1.


Thanks a lot for your help

Read the instructions below carefully. The instructions must be followed. This assignment is worth 5% of your grade. The assignment is due on Monday 19th of October 8AM. No late assignments will be accepted. The goal of this assignment is to learn and practice (via programming and quizzes) the concepts that we have learned in the last two weeks: function design, function calls, branching (that is, if statements), strings, for-loops . .. Some of these concepts will be covered more on Monday/Tuesday class (5/6 Oct). But you can certainly already work on many of the questions. This assignment has two parts. Each part explains what needs to be submitted. Put all those required documents into a folder called a2_xxxxxx, zip it and submit it as explained in lab 1. (In particular, the folder should have the following Fles: a2_part1_xxxxxx.py, a2_part2_xxxxxx.py and a2_part2_xxxxxx.txt ±or each function that you design for this assignment you have to include docstrings that specify: - type contract - description about what the function does (while mentioning parameter names) - preconditions, if any If you do not know what this means view the coursera 6-min video "±unction Design Recipe" in Week 2. (or revise what we did in class and labs) ***************************************** PART 1 (15 points) ***************************************** Suppose you are asked to design a software tool that helps an elementary school student learn arithmetic operations. The software allows the student to select the arithmetic operation she or he wishes to study. The student chooses from a menu one of two arithmetic operations: Addition and Multiplication. Then the student is asked how many questions would he/she like to be tested on. That number is stored in variable called n. Based on the student's choice and answer, the software tests the student with exactly n questions. If n is zero no test should be performed). ±or each of the n questions, two random positive one-digit integers are generated; then the student is asked to enter the answer for the arithmetic operation applied to the two numbers. At the end, the software displays a message “Well done! Congratulations.” if at least 80% of the questions are answered correctly; if at least 60% but less than 80% of the questions is answered correctly, the program should display "Not too bad but please study and practice some more.", otherwise, the program should display "Please study more and ask your teacher for help.". a) Implement a Python function, called, perform_test, that will execute all the arithmetic tests for a student for multiplication or addition operations. The function has two input parameters; the Frst one is an integer, 0 or 1, that represents the required operation (1 for multiplication and 0 for addition), the second one is a positive integer n representing the number of questions in the test. Then it gets the student to answer
Background image of page 1
n questions as follows: 1. Randomly generates two positive one-digit integers. 2. Ask the student to enter the answer for the arithmetic operation of the two numbers. 3. Checks if the result is correct. If the answer is incorrect, it provides the correct answer. As questions are answered, the correct answers are counted. The number of correct answers is returned by the function. b) (Outside of the function) implement the main part of the program to interact with the student to obtain the choice for either multiplication or addition and the number of questions, then call the function developed in part (a) to test the student (recall that the function returns the number of correct answers). Then print one of three possible messages to the student (“Well done! Congratulations.” or "Not too bad but please study and practice some more." or "Please study more and ask your teacher for help.", as determined by the criteria listed above). Store your program in Fle called a2_part1_xxxxxx.py Test it by pressing Run Module. View the video I made called a2_part1_example_run.mp4 to see how your program should behave when you run it. Note that to generate a random number Frst import module called random and then use the following function random.randint Here is what help(random.randint) gives: "randint(a, b) method of random. Random instance Return random integer in range [a, b], including both end points." ***************************************** PART 2 ***************************************** This part resembles assignment 1. Each question asks you to design one function. Put all these functions (for all the questions in this part) in one Fle only, called a2_part2_xxxxxx.py (where xxxxxx is replaced with your student number). Within this Fle, a2_part2_xxxxxx.py, separate your answers (i.e. code) to each question with a comment that looks like this: ################################################################### # Question X ################################################################### Similarly to assignment 1, in addition to a2_part2_xxxxxx.py you have to submit a separate Fle called a2_part2_xxxxxx.txt with your function tests copy pasted there. If you do not know what this means, read the Assignment 1 description again. Your program must run without syntax errors. The questions that have syntax errors will receive zero points. More speciFcally, for each of the functions below, I have provided one or more tests to test your functions with. To obtain a partial mark your function may not necessarily give the correct answer on these tests. But if your function gives any kind of python error when run on the tests provided bellow, that
Background image of page 2
Show entire document
Sign up to view the entire interaction

Top Answer

The way to approach this... View the full answer

a2_part1_xxxxxx.py

import random
def perform_test(operation, numQ):
correctCount = 0
while numQ > 0:
randomeNumber1 = random.randrange(0,9) ;
randomeNumber2 = random.randrange(0,9) ;
if(operation ==0):
userAnswer...

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online