2 Lab Questions 1. Primary arithmetic. Write a program (called q1.py) that adds
ID: 3863432 • Letter: 2
Question
2 Lab Questions 1. Primary arithmetic. Write a program (called q1.py) that adds two numbers and counts the number of carry operations. You will define your own defined functions for this problem. Your solution must make use of at least two user-defined functions to receive full credit Programming tips There are a number of different ways to tackle this problem. Consider first working on printing out the addition equation as shown in the following examples. Then, work on computing the number of carries required for the addition. Finally, a built-in function that you may find useful to incorporate in your program is max For example, to find the maximum of the 3 numbers 54, 198, and -34, use max (54, 198 34), which returns 198Explanation / Answer
num1 = int(input('Number #1: ')) num2 = int(input('Number #2: ')) num1Len = len(str(num1)) num2Len = len(str(num2)) print() def TotalNumOfCarryOpration(): numb1 = str(num1) numb2 = str(num2) crNum= 0 carryOpration = 0 len1 = num1Len len2 = num1Len if (num1LenRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.