Answer to Question #321082 in Python for Maneo

Question #321082

please find the attached question, https://drive.google.com/file/d/1D_kSUCgtpxyr5Qw68aW21xFndMrhn_Vv/view?usp=sharing


1
Expert's answer
2022-03-31T11:44:44-0400

a)

i)A variable is an identifier whose value can change. That's why the name is. A parameter is an identifier that takes a value. That is, the variable specified in parentheses of the function is a parameter.


ii)The while loop is used in Python to repeatedly execute a specific instruction as long as the specified condition remains true. This loop allows the program to iterate through a block of code. while test_expression: body of while. First, the program evaluates the while loop condition. If it is true, the loop starts, and the while body is executed. The body will be executed as long as the condition remains true.

The for loop in Python is designed to iterate through elements of data structures and some other objects. This is not a loop with a counter, which is for in many other languages. What does it mean to iterate over the elements? For example, we have a list consisting of a number of elements. First we take the first element from it, then the second, then the third, and so on. With each element, we perform the same actions in the for body.


b)

A function is a block of organized, reusable code that is used to perform a specific task. The functions provide better modularity of the application and significantly increase the level of code reuse.


c)

from decimal import Decimal

hours = int(input("number of hours: "))
rate = Decimal(input("rate per hour: ")).quantize(Decimal("1.00"))

print("gross pay:", hours * rate)


d)

passcode = "X-DSPAM-Confidence:0.8475"
number = float(passcode[passcode.find(":") + 1:])
print(number)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS