首页 > > 详细

ITI 1120 - Assignment 2

 

Instructions
This assignment is to be done INDIVIDUALLY.
You have been provided with skeletons for each of the questions (hw2q1.py, …, hw2q4.py).
Please complete them, then zip them in a file hw2.zip and submit it in Brighspace.
Note:
a) Your program MUST run without syntax errors. In particular, when grading your assignment,
TAs will first open your files with IDLE and press Run Module. If pressing Run Module causes
any syntax error, the grade for the whole assignment will be zero.
b) Please don't modify any headers. If you do, all points related to that question or sub-question
will be deducted.
Question 1 Implement a Python function to calculate the body max index (BMI). In the main
part of the program, ask the user to input the weight in kilograms and the height in meters and
call the function. Based on the value retuned by the function, print a message describing the
result (“underweight” if BMI < 18.5, “normal weight” if 18.5 <= BMI < 25, “overweight” if
25<= BMI <30, and “obese” if BMI >=30.
Question2 Implement a Python function that prints integers from a to b. The main part of the
program should ask the user to input a and b and call the function.
Question 3 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. Based on the student choice, the software tests the user
with exactly 10 questions. For each question, 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.
The software displays the number of correct answers and the message “Congratulations!” if more
than 6 questions are answered correctly, otherwise, the program should display "Please ask your
teacher for help".
a) Implement a Python function to execute the arithmetic test for a student for multiplication
or addition operations. The function receives as parameter an integer that represents the
required operation (1 for multiplication and 0 for addition). Then it gets the student to
answer 10 questions as follows:a. Randomly generates two positive one-digit integers.
b. Ask the student to enter the answer for the arithmetic operation of the two
numbers,
c. 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) Implement the main part of the program to interact with the student to obtain the choice
for either multiplication or addition, then call the function developed in part (a) to test the
student (recall that the function returns the number of correct answers). Then print the
number of correct answers, followed by one of two possible messages
(“Congratulations!” or "Please ask your teacher for help", depending on whether the
student gets more than 6 correct answers or not).
Question 4 Modify your Python program from Q1 so that the user is tested with 10 questions
that are randomly distributed between multiplication and addition. It should also provide the
correct answer for the questions that were answered incorrectly. The modifications are as
follows:
a) Modify the function to receive an integer representing the required operation (1 for
multiplication or 0 for addition), then generate two random numbers, and returns true if
the user has answered the question correctly and false if not.
b) Modify the main part of the program to generate a random integer (0 or 1) value
representing one of the two operations and send the Boolean value to the function to
perform the test (note that the program should call the function 10 times, once for each
question). Then the program counts the number of correct answers and prints it, followed
by one of two possible messages to the student (“Congratulations!” or "Please ask your
teacher for help", depending on whether the student gets more than 6 correct answers or
not).
联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点文章
程序代写更多图片

联系我们 - QQ: 99515681 微信:codinghelp
© 2014 www.7daixie.com
程序代写网!