7. In the following question, we will practice writing loops and functions. (a) Create a variable named a and set it equ

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

7. In the following question, we will practice writing loops and functions. (a) Create a variable named a and set it equ

Post by answerhappygod »

7 In The Following Question We Will Practice Writing Loops And Functions A Create A Variable Named A And Set It Equ 1
7 In The Following Question We Will Practice Writing Loops And Functions A Create A Variable Named A And Set It Equ 1 (46.17 KiB) Viewed 35 times
7. In the following question, we will practice writing loops and functions. (a) Create a variable named a and set it equal to 5. Create a variable named b and set it equal to 3. Print (or display) the product of a x b. (b) Write a loop which prints the value of a x b as long as the value of b is strictly less than the value of a. On each loop decrement (reduce) the value of a by 1. (c) Write a function which takes two parameters (a and b). The function should print the same values as Question 7b, i.e. as long as b is strictly less than a, it should print the product of a x b, decrementing the value of a after each calculation. Your function should return the last calculated product. (d) Call to the function you wrote in Question 7c, passing the originally specified values of a (5) and b (3). Save the output as a variable named final. (e) Write a conditional statement. If the value of final is greater than or equal to 10, print the value of final Otherwise print the text, "Less than 10."
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply