Question

Create a * Python main program* which
calls two functions enterNum and calcResult and accomplishes the
following:

1. The main program calls the function enterNum 3 times. The first time enterNum is called, the main program stores the returned output in the variable xx. The second time, the returned output is stored in the variable yy and the third time in zz.

2. enterNum asks the user to enter a floating point number. This function has no input arguments and returns only one floating point output to the main program each time it is called.

3. The program then calls a function calcResult, which accepts xx, yy and zz as input arguments, adds xx + yy and subtracts zz from that term. The result of the computation is returned to the main program.

4. The main program then prints the result returned by the function calcResult. Print only from the main program, not the function.

Answer #1

**Screenshot:-**

**Code:-**

def enterNum():

n=int(input("Enter the number: "))

return n

def calcResult(xx,yy,zz):

result = xx+yy-zz

return result

xx=enterNum()

yy=enterNum()

zz=enterNum()

result =calcResult(xx,yy,zz)

print("The result is: ",result)

This python program must have 9 functions:
•main() Controls the flow of the program (calls the other
modules)
•userInput() Asks the user to enter two numbers
•add() Accepts two numbers, returns the sum
•subtract() Accepts two numbers, returns the difference of the
first number minus the second number
•multiply() Accepts two numbers, returns the product
•divide() Accepts two numbers, returns the quotient of the first
number divided by the second number
•modulo() Accepts two numbers, returns the modulo of the...

Question 1
Write functions that do the following:
i) A function that takes 2 arguments and adds them. The result
returned is the sum of the parameters.
ii) A function that takes 2 arguments and returns the
difference,
iii) A function that calls both functions in i) and ii) and
prints the product of the values returned by both.
Question 2
Write functions:
i) One that prompts a user for 2 numbers.
ii) Adds the two numbers if they are...

Write a C++ program which consists of several functions besides
the main() function.
1) The main() function, which shall ask for input
from the user (ProcessCommand() does this) to compute the
following: SumProductDifference and Power. There should be a well
designed user interface.
2) A void function called SumProductDifference(int,
int, int&, int&, int&), that computes the sum, product,
and difference of it two input arguments, and passes the sum,
product, and difference by-reference.
3) A value-returning function called Power(int a,...

FOR PYTHON
Rewrite your pay computation with time-and-a-half for overtime
and create a function called compute_pay which takes two parameters
(hours and rate).
Enter Hours: 45
Enter Rate: 10
Pay: 475.0
YOU WILL NEED THREE FUNCTIONS:
the_hours, the_rate = get_input()
the_pay = compute_pay(the_hours,
the_rate)
print_output(the_pay)
Call the functions and passing the arguments in the "main"
function.
Example:
def main():
the_hours, the_rate = get_input()
the_pay = compute_pay(the_hours,
the_rate)
print_output(the_pay)
main()
-----
Testing the outputs of your code: 1 for the valid...

Module 4 Assignment 1: Pseudocode & Python with Variable
Scope
Overview
Module 4 Assignment 1 features the design of a calculator
program using pseudocode and a Python program that uses a list and
functions with variable scope to add, subtract, multiply, and
divide. Open the M4Lab1ii.py program in IDLE and save it as
M4Lab1ii.py with your initials instead of ii.
Each lab asks you to write pseudocode that plans the program’s
logic before you write the program in Python and...

Create a program that generates a file of random numbers, and
then prints them in neat fashion to another file, and also saves to
that file the average and standard deviation of those numbers.
I) First, you would need to generate a file of random numbers
that consists of N random numbers (100 < N < 1000). Each
random digit should be a real number (type double) between 0 and
50. This file and its digits would now serve as...

** Language Used : Python **
PART 2 : Create a list of unique words
This part of the project involves creating a function that will
manage a List of unique strings. The function is passed a string
and a list as arguments. It passes a list back.
The function to add a word to a List if word does not exist in
the List. If the word does exist in the List, the function does
nothing.
Create a test...

Consider the following python script mt_q2.py, which defines the
function called now():
#!/usr/bin/env python3
# program: mt_q2.py
import os
def now():
p = os.popen('date +%Y%m%d')
today = p.read().strip()
return today
if __name__ == '__main__':
print(now())
Asnwer the following questions:
(a) What type of object will be returned by the
now() function?
(b) If you run the above Python script "python3
mt_q2.py" on a system with real-time clock on Oct 16, 2019
at 10:00 am,
what will...

##4. What will the following program display?
##def main():
## x = 1
## y = 3.4
## print(x, y) ## first printing
## change_us(x, y)
## print(x, y) ##second printing
##
##def change_us(a, b):
## a = 0
## b = 0
## print(a, b)
##
##main()
##
##Yes, yes, main() displays
##1 3.4
##0 0
##1 3.4
## The question is: why x and y are still the same while the
second printing of
(x,y)?
## It seems...

Write a Python program named lastNameVolumes that finds the
volumes of different 3 D objects such as a cube, sphere, cylinder
and cone.
In this file there should be four methods defined.
Write a method named cubeVolFirstName, which accepts the side
of a cube in inches as an argument into the function. The method
should calculate the volume of a cube in cubic inches and return
the volume. The formula for calculating the volume of a cube is
given below....

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 3 minutes ago

asked 18 minutes ago

asked 18 minutes ago

asked 35 minutes ago

asked 35 minutes ago

asked 37 minutes ago

asked 42 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago