Part B
There are many different ways that a user could tell us that he or she would like to add two numbers in our calculator program. The user could type “add”, “Add”, “ADD”, or “+”, to name a few possibilities. Of course, as humans, we know exactly what is meant, even if the word is capitalized. But the Python Interpreter can’t tell that “add” is the same as “Add”.

We can use a list to make our program a bit more robust. We can also use the IN operator to check for certain values in that list. Take a look at this if statement’s opening line:

if operation in [“add”, “Add”, “ADD”, “+”]:
Make those changes in your program and verify that it works.
Consider all of the possible words the user might enter to subtract, multiply, or divide.
Rewrite the first lines of each of your if statements to use lists.
Thoroughly test your new program, trying out each of the four operations.
Share the link to your Python code in REPL.it with your teacher by clicking on the share button and copying the link.

Answers

Answer 1

Answer:

The Python programming language is a great tool to use when working with numbers and evaluating mathematical expressions. This quality can be utilized to make useful programs.

This tutorial presents a learning exercise to help you make a simple command-line calculator program in Python 3. While we’ll go through one possibile way to make this program, there are many opportunities to improve the code and create a more robust calculator.

We’ll be using math operators, variables, conditional statements, functions, and handle user input to make our calculator.

Prerequisites

For this tutorial, you should have Python 3 installed on your local computer and have a programming environment set up on the machine. If you need to either install Python or set up the environment, you can do so by following the appropriate guide for your operating system.

Step 1 — Prompt users for input

Calculators work best when a human provides equations for the computer to solve. We’ll start writing our program at the point where the human enters the numbers that they would like the computer to work with.

To do this, we’ll use Python’s built-in input() function that accepts user-generated input from the keyboard. Inside of the parentheses of the input() function we can pass a string to prompt the user. We’ll assign the user’s input to a variable.

For this program, we would like the user to input two numbers, so let’s have the program prompt for two numbers. When asking for input, we should include a space at the end of our string so that there is a space between the user’s input and the prompting string.

number_1 = input('Enter your first number: ')

number_2 = input('Enter your second number: ')

After writing our two lines, we should save the program before we run it. We can call this program calculator.py and in a terminal window, we can run the program in our programming environment by using the command python calculator.py. You should be able to type into the terminal window in response to each prompt.

Output

Enter your first number: 5

Enter your second number: 7

If you run this program a few times and vary your input, you’ll notice that you can enter whatever you want when prompted, including words, symbols, whitespace, or just the enter key. This is because input() takes data in as strings and doesn’t know that we are looking for a number.

Explanation:

Hope This helps with your coding

( If it doesn't then sorry)


Related Questions

What is web
searching engine ?​

Answers

A Web search engine is a specialized computer server that searches for information on the Web. The search results of a user query are often returned as a list. The hits may consist of web pages, images, and other types of files.

Can someone tell me 5 facts about Registers and RAM, please?

Answers

[tex]\int\limits^a_b {x} \, dx \left \{ {{y=2} \atop {x=2}} \right. \lim_{n \to \infty} a_n \neq \neq \geq[/tex]Answer:

A register is a temporary storage area built into a CPU. ... The instruction register fetches instructions from the program counter (PC) and holds each instruction as it is executed by the processor. The memory registers are used to pass data from memory to the processor.

PLS MARK BRAINLIEST!!!

PLEASE

:

Read the code snippet below and determine which markup language it is:



Sound Card
Creative Labs
Sound Blaster Live
80.00



The code is an example of the (Blank) markup language.

Answers

Answer:

Sound Card

Explanation:

Choose all items that are true about the two example of HTML shown on the right.
A. Example 1 will display differently than example 2 in a web browser.
B. They are styled differently, but will look the same in a web browser.
C. Example 2 is easier to analyze and repair.
D. The styling in example 2 is required by modern web browsers.

Answers

Answer:

“They are styled differently, but will look the same in a web browser” & “The styling in example 2 is required by modern web browsers”.

Explanation:

Answer:

B and C

Explanation:

Boolean Operators help filter information when completing a ________ ________

A. web search
B. column making​

Answers

The answer would be A: Web Search :)

I really need help with this question, I can’t fail this please :) tysm

Answers

Answer:

i think its the third one, i hope this helps

Explanation:

Can someone please help me with this assignment on Edhesive. I just need the storyboard and code. thank you.

Answers

Answer:

i need points im so sorry

Explanation:

True or False? Security code is almost always open source!
True
False

Answers

Answer:

its true

Step-by-step explanation:

Security code is almost always open source is a false statement. Check more about  Security code below.

What is security code?

The  Security code  is known to be the number that is known to be found in the front or back of any credit cards. It is made just  for security use.

Conclusively,  Security code is almost always open source as one cannot get it except one is told about it. Therefore, it is not an open source.

Learn more about  Security code from

https://brainly.com/question/26260220

what is the importance of knowing and following a step /steps of the personal computer disassembly

Answers

So that in case of emergency caomeone spills food or liquid you know what precautions to take

Answer:

emergency pils at a doctor

In many supermarkets customers can pay for their shopping using credit cards. (a) Name two items of information stored on the magnetic stripe on these cards. (b) State two ways that the supermarket computer would check the credit card.

Answers

Answer:

Explanation:

Two items on the magnetic strip are, Credit Card info and Balance

Two ways supermarket may check are the PIN pad you are using to pay or their reciept system.

how many people in the world

Answers

Answer:

Around seven billion people

what three factors helped the Wright brothers achieve success in controlled sustained and powered flight?​

Answers

In 1903 the Wright brothers achieved the first powered, sustained and controlled airplane flight; they surpassed their own milestone two years later when they built and flew the first fully practical airplane.

Write a program code to accept the names of 3 users and generate a user name as shown in the example. Accept the name of 3 user in the format – Firstname Last name (eg. Anan Gupta). Select the first 3 characters from the first name, add # and then add last 3 characters of the last name. Display the newly generated user name along with the names that were input.

Answers

Answer:

Explanation:

The following code is written in Python and is a function that loops three times asking for the last name and first name. Then it uses this information to create a username. Finally, each of the names and usernames is printed on the screen.

def userName():

   for x in range(3):

       last_name = input("What is your last name: ")

       first_name = input("What is your first name: ")

       username = first_name[:3] + "#" + last_name[-3:]

       print(last_name + ", " + first_name)

       print(username)

Which of the following is NOT an acceptable way to create a color?


A) O "cyan"
B) O "#ff2341"
C) blue
D) "RGB (0, 15, 234)"

Answers

The option that is not an acceptable way to create a color is blue.

How can I create a color?

There are a lot of ways to create  some unique color  such as the additions of  colors together.  An example is the addition of purple, orange, and green together.

Note that blue on its own cannot create another color and as such, The option that is not an acceptable way to create a color is blue.

Learn more about color from

https://brainly.com/question/4431200

#SPJ2

Choose the best option to answer each question on design or development.

Answers

i am sorry. I cannot see the options...

Answer:

design

requirements

code

(in that order)

Explanation:

it was right on edge


what is
Force (N) = Mass (kg) x acceleration (m/s)

If a 80-kg swimmer pushes off a pool wall with a force of 225 N, at what rate with the swimmer

accelerate forward?​

Answers

Hope this really helps u with your studies
225/80=2.8125m/s

why would computer programmers want to use an object to change the instructions they already created in a computer program ​

Answers

Answer:

bank rupt

Explanation:

no money on your card lol have  a graey day dont wish for what your not willing to work for

1 Sales tax
5.00%
Use the image to help you answer the question.
Which formula will tell you the total "Before tax"
price using cell references?

A. =3+2+50
B. =B8
C. =B4+B5+B6
D. =B4*B5*B6

Answers

Answer:

Future value (FV) tells you the value in the future of money deposited in a bank account ... We can use Excel to make a table of how the future value grows with the ... 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. A. B. C. D. E. F. Interest. 6% ... To answer the question, we compute the IRR of the investment and compare it.

Explanation:

Answer:

C. = B4+B5+B6

Explanation:

Edge 2020

Write a program to convert centigrade to Kelvin. It should display value in centigrade and then the value in Kelvin just as you displayed squares in the previous question. The range to be followed for this conversion is from 50-100 degree celsius.

So, it should look like this:
1. Centrigrade: 50 --> Kelvin: 323.15
2. Centrigrade: 51 --> Kelvin: 324.15
3. Centrigrade: 52 --> Kelvin: 325.15
etc.

Answers

Answer:

for degree in range(50, 101):

   kelvin = degree + 273.15

   print("Centrigrade: {} --> Kelvin: {}".format(degree, kelvin))

Explanation:

*The code is in Python.

Create a for loop that iterates from 50 to 100 (Note that the starting value is included, but the ending value is not included in the range method. That is why you need to write range(50, 101) to iterate from 50 to 100)

Convert the centigrade to kelvin using formula (Note that the degree variable represents the each centigrade degree from 50 to 100 and you need to add 273.15 to convert it to Kelvin)

Print the result as in requested format

True or false: Machine learning lets computers
learn how to do things they weren't
specifically programmed to do.

Answers

Answer:

True

Explanation:

PLEASE ANSWER ASAP!!!

Name the error that can happen as a result of adding binary numbers.

Answers

Answer:

Sometimes, when adding two binary numbers we can end up with an extra digit that doesn't fit. This is called an overflow error. This sum is fine as the original numbers have two digits, and the result of the sum also has two digits.

Explanation:

Can someone help me figure out why my else statment is not working?




----------------------------------------------------------------------------------------------------------------------------
print("\tBank of The Funny Money Bunny Farm\n")
print("Client\t\tDeposits\tWithdrawals\tBalance\t\tNotes:")
print("__________________________________________________________________________________________________________________________")

names = ['Judith', 'Jimmie', 'Johnny', 'Joseph', 'Jeffry', 'Buddie', 'Charlie', 'Maxine', 'Jannis', 'Bodine']
deposists = [255.23, 525.55, 323.21, 651.48, 507.11, 101.11, 253.36, 323.22, 611.45, 252.91]
withdrawals = [255.76, 128.65, 156.22, 175.33, 390.12, 255.41, 128.22, 156.23, 728.98, 251.43]
balance = []
notes = []

for i in range(len(names)):
balance.appened(deposits[i] - withdrawals[i])
if(balance < 0):
print((names[i] + ", you are overdrawn. Your account balance is " + "$%.2f"%(balance[i]))
else:
print("" + names[i] + "\t\t" + "%.2f"%(deposits[i]) + "\t\t" + "%.2f"%(withdrawals[i]) + "\t\t" + "%.2f"%(balance[i]) + "\t\t" + notes[i])

print("__________________________________________________________________________________________________________________________")
print("\© Copyright 2021 Funny Bunny Money Productions")

#Main

print("\tBank of The Funny Money Bunny Farm\n")
account = int(input("How many new accounts are needed: "))
for i in range(account):
input("Enter the name of the client: ")
input("Enter the deposist of the client: ")
input("Enter the withdraral of the client: ")

Answers

Answer:

below is a version of your code that runs.

I'm not sure if it does what you expect it to do.

Why is it a good practice to use functions in programming? Select the best answer.

A.It is faster to run the code using functions.

B.Functions allow us to reuse common code.

C.All of these are correct.

D.It is easier to debug the code using functions.

Answers

Answer:

C. All of these are correct answer from the options for the question that u have given...

The good practice to use functions in programming is all of these are correct. The correct option is C.

What are functions in programming?

The repetitious codes are removed by breaking a program down into functions, which not only reduces the size of the program but also improves its effectiveness. If there were repetitive codes, we would need to alter the program from several locations rather than just one.

As a result, organizing programs into functions aid in good administration and shortens programs by removing repeated code. A functional programming language is a particular kind of language that allows for the creation and application of pure mathematical functions, along with the use of conditional expressions and recursion to carry out various computations.

Therefore, the correct option is C. All of these are correct.

To learn more about functions in programming, refer to the link:

https://brainly.com/question/24297344

#SPJ6

You have a database with three tables: one each for products, suppliers, and distributors. You need to locate the product ID number for hammers and find out who supplies them. Which database component would perform this task?

A. Form
B. Table
C. Report
D. Query

Answers

Answer:

I would say A... But that's just me

Explanation:

Hopefully this helps you :))

Answer:

The answer is C: Query

Explanation: I just did it in Edge 2021. Trust me its right! I hope this helps! :)

how do you do the ask tutor thing on the computer?

Answers

Answer:

what do you mean

Explanation:

Help ASAP this assignment is due today!!!!

Answers

You want someone to do your assignment???

Someone please tell me what lambda does! in python!! I need help

Answers

Answer:Lambda Technologies is the he is the group name encompassing a Premier materials research laboratory with an engineering and production enterprise dedicated to the development and optimization of of surface treatments our company has been selling materials for over four decades with over 150 years of combined experience in more than 20,000 research programs we are proud of our corporate legacy in record or around standing performance in meeting or customers needs room training all excellence groundbreaking innovation and committed hard-working employees we are able to provide more than just data we provide complete service enhancement solutions are resources that can include all of our technical papers he studies defraction notes and downloads we are a well known source of research in education materials on the understanding measurement and controls of residual stress

Explanation:

Identify one audience for The Sun Website

Answers

Answer:

69

Explanation:

Why Should You Love Your Job?

Answers

Answer:

I think you should love your job because if you get good grades in high school and collage you get to pick your job and it will be amazing for you in life!

Hope that helped :)

ayo which one is better genshin impact or fortnite, i personally prefer genshin impact since it's not boring and it has so many other things you could do when you're not doing a story quest or daily commissions

Answers

Answer:

Genshin Impact and you can fight me on it.

Explanation:

The game has way more to explore and offer with different fighting styles which include Magic and Swords fighting. It also has more story and I appreciate that!  

The side quests to get tedious though so the final rating  is 8.79//10.00

Answer:

genshin

Explanation:

Other Questions
Please I would be grateful I need help Which graph represents y = 4x + 4? HURRY PLEASE HELP!! Vosotros/ponerse/los pantalones(pents). A collection of sketches is known as a? Match the correct action to what is happening in the cell.1. Break open the cell2. Dissolve the membranes 3. Separate the organelles, broken cell walls, and membranes from proteins, carbohydrates and DNA4. Precipitate the DNA(clump the DNA together)A. Squish the fruit to a slushB. Filter your extract through cheeseclothC. Layer cold alcohol over the extractD. Mix in a detergent(soap) solution 6/13 as a decimal rounded to the nearest thousandth PLEASE HELP I NEED MORE PLEASE WORTH 1O POINTS How many 1/4s are in 2/3? Only hash channel catfish typically was about 0.06 g during the first six weeks of life at weight increase about 10% each day right a exponential model for the weight how much will the catfish gain weight after six weeks Please help with number 1 and 4 asap! HURRY PLEASEEEEThe Continental Divide and the Rocky Mountains are different landforms. T OR F is wearing facemask necessary for all people?why or why not? There are six elements that are common to all Logistic Regression is a type of __________ problem. Which set of ordered pairs represents a function?{(-8, 1), (5. 7),(-6,9), (-6, -9)}o{(-2,-3), (2, 1), (2,6), (4,9)}o{(8,4), (6,4), (9,1),(7-6)}o{(-4,5),(0,0), (2, -8), (2,0)} how does a decrease in potential energy during a chemical rwaction relate to the temperature of the surroundings PLEASE HELP!!!! WILL GIVE BRAINLIEST!!!!!! I need help with both parts, ill give brainliest and 30 pointsPart A: What changes does sugar undergo when heated in a spoon over the flame?Select one:A. A physical change, then a chemical changeB. Two physical changesC. Two chemical changesD. A chemical change, then a physical changePart B: What evidence from the experiment and data table best supports your answer to Part A? Use information from the stimulus material and your knowledge of science to support your answer. In your answer, be sure to:Desribe the evidence that supports your answer to Part A.Provide your reasoning why that evidence supports your answer to Part A. How does inertia explain why it is difficult to stop a movingskateboard? True or False: Monroe ran unopposed for a second term as president, receiving 100% of the Electoral College votes.