Hello! I'm looking for help with this assignment.
Complete a program in pseudocode and Python that performs the following tasks.
How to Complete Your M4 Assignment 1 Pseudocode & Python with Variable Scope
# Calculator Program
# M4Lab1ii.py for M4 Assignment 1
# C. Calongne, 01/19/19
# Seven steps to complete in this lab:
# Define a list to store the choices for +, -, *, /
# Define 3 functions with local variables
# Define three elif statements that call the functions for -, *,
and /
# Local variables are visible in the functions
# Pass the input values into them.
# Continue calculating until the user presses "n"
print("Welcome to your Calculator program")
# The add function adds two numbers
def add(x, y):
return x + y
# local scope; only the add() function sees x and y
#write the other three functions for subtract, multiply and divide
# Step 1: Write a subtract function that subtracts two numbers
# Step 2: Write a multiply function that multiplies two numbers
# Step 3: Write a divide function that divides two numbers
# Start calculating
# Step 4: define a list called choice with + - * / in it
keep_going = ["y", "n"] # only tests for "n"
while keep_going != "n":
num1 = float(input("Enter first number: "))
choice = input("What kind of calculation? Choose one of: +, -, *, /
")
num2 = float(input("Enter second number: "))
if choice == "+":
# choice is a list with the string value for "+"
# The test for choice returns the value True or False. If true:
print(num1, choice, num2,"=", add(num1,num2))
# calls the add function and passing it two parameters
# finish the rest of the if statement for the other 3
calculations
# Step 5: write an elif for subtract
# Step 6: write an elif for multiply
# Step 7: write an elif for divide
else:
print("Invalid input")
keep_going = input("Calculate? y or n? ")
print("Closing the calculator.")
Dear Student ,
As per requirement submitted above kindly find below solution.
main.py :
print("Welcome to your Calculator program")
# The add function adds two numbers
def add(x, y):
return x + y
# local scope; only the add() function sees x and y
#write the other three functions for subtract, multiply and
divide
# Step 1: Write a subtract function that subtracts two
numbers
def subtract(x, y):
return x- y
# Step 2: Write a multiply function that multiplies two
numbers
def multiply(x, y):
return x*y
# Step 3: Write a divide function that divides two numbers
def divide(x, y):
return x/ y
# Start calculating
# Step 4: define a list called choice with + - * / in it
choice=['+','-','*','/']
keep_going = ["y", "n"] # only tests for "n"
while keep_going != "n":
num1 = float(input("Enter first number: "))
choice = input("What kind of calculation? Choose one of: +, -, *, /
")
num2 = float(input("Enter second number: "))
if choice == "+":
# choice is a list with the string value for "+"
# The test for choice returns the value True or False. If
true:
print(num1, choice, num2,"=", add(num1,num2))
# calls the add function and passing it two parameters
# finish the rest of the if statement for the other 3
calculations
# Step 5: write an elif for subtract
elif choice == "-":
print(num1, choice, num2,"=", subtract(num1,num2))
# Step 6: write an elif for multiply
elif choice == "*":
print(num1, choice, num2,"=", multiply(num1,num2))
# Step 7: write an elif for divide
elif choice == "/":
print(num1, choice, num2,"=", divide(num1,num2))
else:
print("Invalid input")
keep_going = input("Calculate? y or n? ")
print("Closing the calculator.")
******************************
Screen for indentation :


==================================
Output :Compile and Run main.py to get the screen as shown below
Screen 1:main.py

NOTE :PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
Hello! I'm looking for help with this assignment. Complete a program in pseudocode and Python that...
Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that uses iteration to guess a number from 1 to 10. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. Instructions Write pseudocode for a Python program that uses iteration to guess a number from...
Overview Module 3 Assignment 2 features designing a program using pseudocode and then completing the program in Python using strings. M3Lab2 asks you to write a Mortgage Loan Calculator. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. Instructions Pseudocode and Python Program with Strings M3Lab2.txt has some of the...
SEE THE Q3 for actual question, The first Two are Q1 and Q2 answers . Q1 #include<iostream> using namespace std; // add function that add two numbers void add(){ int num1,num2; cout << "Enter two numbers "<< endl; cout << "First :"; cin >> num1; cout << "Second :"; cin >>num2; int result=num1+num2; cout << "The sum of " << num1 << " and "<< num2 <<" is = "<< result; ...
Hello, In Python Enhance the prior assignment by doing the following 1) Create a class that contain all prior functions MyLib # This function adds two numbers def addition(a, b): return a + b # This function subtracts two numbers def subtraction(a, b): return a - b # This function multiplies two numbers def multiplication(a, b): return a * b # This function divides two numbers # The ZeroDivisionError exception is raised when division or modulo by zero takes place...
I need help with my python class. thanks! Question 12 Code Example 4-4 main program: import arithmetic as a def multiply(num1, num2): product = num1 * num2 result = a.add(product, product) return result def main(): num1 = 4 num2 = 3 answer = multiply(num1, num2) print("The answer is", answer) if __name__ == "__main__": main() arithmetic module: def add(x, y): z = x + y return z Refer to Code...
C++ I am using visual studio for it. Make a copy of the Rational class you created in the previous Lab. Modify the class. Replace all your mathematical, input, and output functions with overloaded operators. Overload the following 12 operators: + - * / < > = = ! = <= >= >> << In order to test your class in your main function, prompt the user for a numerator and a denominator for your first object. Repeat the prompt...
1.Write a Python program to perform simple arithmetic operations (add, subtract, multiply and divide) on 2 numbers and display the output on console ( use methods in your program) Range of numbers : 1 to 100 (Do not use 0)
Question 20: Write a python program that will perform the operations of simple calculator. The operations are : Addition, subtraction, Multiplication and division. Sample output : Select operation. 1.Add 2.Subtract 3.Multiply 4.Divide Enter choice(1/2/3/4): 3 Enter first number: 15 Enter second number: 14 15 * 14 = 210
may i ask for help with this c++ problem?
this is the code i have for assignment 4 question 2:
#include<iostream>
#include<string>
#include<sstream>
#include<stack>
using namespace std;
int main()
{
string inputStr;
stack <int> numberStack;
cout<<"Enter your expression::";
getline(cin,inputStr);
int len=inputStr.length();
stringstream inputStream(inputStr);
string word;
int val,num1,num2;
while (inputStream >> word)
{
//cout << word << endl;
if(word[0] != '+'&& word[0] != '-' && word[0] !=
'*')
{
val=stoi(word);
numberStack.push(val);
// cout<<"Val:"<<val<<endl;
}
else if(word[0]=='+')
{
num1=numberStack.top();
numberStack.pop();
num2=numberStack.top();
numberStack.pop();...
Write a C program as follows: Single source code file Requests the user to input two integer numbers Requests the user to make a choice between 0 (add), 1 (subtract), or 2 (multiply) Declares three separate functions Uses a pointer to these three functions to perform the requested action Outputs the result to the screen Submit your program source code file to this assignment. Sample Output Enter first integer number: 15 Enter second integer number: 10 Enter Choice: 0 for...