Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 2.7, Problem 19CP
Program Plan Intro
Evaluating expression:
An expression is a statement that will hold a value when it gets evaluated. A mathematical expression will hold multiple operators and grouping symbols. An expression will get evaluated based on the precedence of an operator.
Precedence of the operator:
- • Unary negation (-) and brackets () will have the highest priority.
- • Multiplication (*), division (/), and modulus (%) will have the next highest priority.
- • Addition (+) and subtraction (-) will have the lowest priority.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
9- In the following figure, there is one (combobox), one (textbox), one (button) and one (label). There are two function options in the ComboBox called "Cos" and "Sin". The numeric value entered in degrees in the text box is subjected to the function selected from the drop-down box, and the result is written in the "result" section. Type the program that performs this function.
(Tip: you can use math.Cos and math.Sin functions. These functions use the type radian value as a parameter.)
Create an application using VISUAL BASIC that when the user clicks a button, call a sub procedure to input a student name, size and quantity of shirts ordered. Write a function to order price based on the rule: If the size is Small or Medium, the price is $10 per shirt, otherwise the price is $12.00 per shirt. Output to a label as shown using a sub procedure. (Use input validation where necessary). Your calls to your sub procedures and a function should look like this in the click event procedure of the button:
Dim name as String
Dim size as String
Dim qty as Integer
Dim price as Double : :
InputShirtInfo(name, size, qty)
price = CalcPrice(size, qty)
OutputOrderInfo(name, price)
Using Figure 3,
c) write a piece of code in C# that calculates the area of a triangle displaying the area in the
area textbox. [5]
d) write a piece of code in C# that changes the colour of the form to Red when the form is
loading. [5]
e) write a piece of code in C# that changes the colour of the colour of the Height textbox to
lime when the mouse hoovers over the Base textbox.
Chapter 2 Solutions
Starting Out with Python (4th Edition)
Ch. 2.1 - Who is a programmers customer?Ch. 2.1 - What is a software requirement?Ch. 2.1 - What is an algorithm?Ch. 2.1 - What is pseudocode?Ch. 2.1 - Prob. 5CPCh. 2.1 - Prob. 6CPCh. 2.3 - Write a statement that displays your name.Ch. 2.3 - Write a statement that displays the following...Ch. 2.3 - Write a statement that displays the following...Ch. 2.5 - Prob. 10CP
Ch. 2.5 - Which of the following are illegal variable names...Ch. 2.5 - Prob. 12CPCh. 2.5 - Is the following assignment statement valid or...Ch. 2.5 - Prob. 14CPCh. 2.5 - Look at the following assignment statements:...Ch. 2.5 - What will be displayed by the following program?...Ch. 2.6 - You need the user of a program to enter a...Ch. 2.6 - Prob. 18CPCh. 2.7 - Prob. 19CPCh. 2.7 - Prob. 20CPCh. 2.7 - Prob. 21CPCh. 2.8 - How do you suppress the print functions ending...Ch. 2.8 - How can you change the character that is...Ch. 2.8 - Prob. 24CPCh. 2.8 - Prob. 25CPCh. 2.8 - What does the statement print (format (65.4321,...Ch. 2.8 - What does the statement print (format (987654.129,...Ch. 2.9 - What are three advantages of using named...Ch. 2.9 - Write a Python statement that defines a named...Ch. 2.10 - Prob. 30CPCh. 2.10 - Prob. 31CPCh. 2.10 - Prob. 32CPCh. 2.10 - Prob. 33CPCh. 2.10 - Prob. 34CPCh. 2.10 - Prob. 35CPCh. 2.10 - Prob. 36CPCh. 2.10 - Prob. 37CPCh. 2.10 - Prob. 38CPCh. 2.10 - Prob. 39CPCh. 2.10 - Prob. 40CPCh. 2.10 - Prob. 41CPCh. 2.10 - Prob. 42CPCh. 2.10 - Prob. 43CPCh. 2.10 - Prob. 44CPCh. 2.10 - Prob. 45CPCh. 2 - A ______ error does not prevent the program from...Ch. 2 - Prob. 2MCCh. 2 - A(n) __________ is a set of well-defined logical...Ch. 2 - An Informal language that has no syntax rules and...Ch. 2 - A _______ is a diagram that graphically depicts...Ch. 2 - A ______ is a sequence of characters. a. char...Ch. 2 - Prob. 7MCCh. 2 - Prob. 8MCCh. 2 - A string literal in Python must be enclosed in...Ch. 2 - Prob. 10MCCh. 2 - A(n) __________ makes a variable reference a value...Ch. 2 - This symbol marks the beginning of a comment in...Ch. 2 - Which of the following statements will cause an...Ch. 2 - In the expression 12 + 7, the values on the right...Ch. 2 - This operator performs integer division. a. // b....Ch. 2 - This is an operator that raises a number to a...Ch. 2 - This operator performs division, but instead of...Ch. 2 - Prob. 18MCCh. 2 - Which built-in function can be used to read input...Ch. 2 - Prob. 20MCCh. 2 - A magic number is _______. a. a number that is...Ch. 2 - A _______ is a name that represents a value that...Ch. 2 - Programmers must be careful not to make syntax...Ch. 2 - In a math expression, multiplication and division...Ch. 2 - Variable names can have spaces in them.Ch. 2 - In Python, the first character of a variable name...Ch. 2 - If you print a variable that has not been assigned...Ch. 2 - What does a professional programmer usually do...Ch. 2 - What is pseudocode?Ch. 2 - Computer programs typically perform what three...Ch. 2 - If a math expression adds a float to an int, what...Ch. 2 - What is the difference between floating-point...Ch. 2 - What is a magic number? Why are magic numbers...Ch. 2 - Assume a program uses the named constant PI to...Ch. 2 - Write Python code that prompts the user to enter...Ch. 2 - Write Python code that prompts the user to enter...Ch. 2 - Write assignment statements that perform the...Ch. 2 - Assume the variables result, w, x, y, and z are...Ch. 2 - Write a Python statement that assigns the sum of...Ch. 2 - Write a Python statement that subtracts the...Ch. 2 - Write a Python statement that multiplies the...Ch. 2 - Prob. 8AWCh. 2 - What would the following display? num = 99 num = 5...Ch. 2 - Assume the variable sales references a float...Ch. 2 - Assume the following statement has been executed:...Ch. 2 - What will the following statement display?...Ch. 2 - Write a turtle graphics statement that draws a...Ch. 2 - Write the turtle graphics statements to draw a...Ch. 2 - Write the turtle graphics statements to draw a...Ch. 2 - Personal Information Write a program that displays...Ch. 2 - Sales Prediction A company has determined that its...Ch. 2 - Land Calculation One acre of land is equivalent to...Ch. 2 - Total Purchase A customer in a store is purchasing...Ch. 2 - Distance Traveled Assuming there are no accidents...Ch. 2 - Sales Tax Write a program that will ask the user...Ch. 2 - Miles-per-Gallon A car's miles-per-gallon (MPG)...Ch. 2 - Tip, Tax, and Total Write a program that...Ch. 2 - Celsius to Fahrenheit Temperature Converter Write...Ch. 2 - Ingredient Adjuster A cookie recipe calls for the...Ch. 2 - Male and Female Percentages Write a program that...Ch. 2 - Stock Transaction Program Last month, Joe...Ch. 2 - Planting Grapevines A vineyard owner is planting...Ch. 2 - Compound Interest When a bank account pays...Ch. 2 - Turtle Graphics Drawings Use the turtle graphics...
Knowledge Booster
Similar questions
- An expression can contain arithmetic, comparison, and logical operators. Indicate the order of precedence for the three types of operators by placing a number (1, 2, or 3) on the line to the left of the operator type. __________ Arithmetic __________ Logical __________ Comparisonarrow_forwardWhat will the following code display?numbers = [1, 2, 3, 4, 5]numbers[2] = 99print(numbers)arrow_forwardcreate flowchart that will arrange the value of A, b and c assending order where a gets the lowest value c gets the highest value the value of a=15 b=10 c=20arrow_forward
- A vertical tab escape sequence. \n O lb If char is a letter of the alphabet, this function returns non-zero; otherwise, it returns zero. O isalphabet() O isletter() O isalpha() () If char is a punctuation character (except the space), this function returns non-zero; otherwise, it returns zero. issymbol 0 ispunct) O ispunctuation) O isspecial()arrow_forwardAssume that the following variables contain the values shown:numberBig = 100numberMedium = 10numberSmall = 1wordBig = "Constitution"wordMedium = "Dance"wordSmall = "Toy”For each of the following Boolean expressions, decide whether the statement is true, false, or illegal.a. numberBig > numberSmallb. numberBig < numberMediumc. numberMedium = numberSmalld. numberBig = wordBige. numberBig = "Big"f. wordMedium > wordSmallg. wordSmall = "TOY"h. numberBig <= 5 * numberMedium + 50i. numberBig >= 2000j. numberBig > numberMedium + numberSmallk. numberBig > numberMedium AND numberBig < numberSmalll. numberBig = 100 OR numberBig > numberSmallm. numberBig < 10 OR numberSmall > 10n. numberBig = 300 AND numberMedium = 10 OR numberSmall = 1o. wordSmall > wordBigp. wordSmall > wordMediumarrow_forwarddef area(side1, side2): return side1 * side2s1 = 12s2 = 6Identify the statements that correctly call the area function. Select ALL that apply. Question options: area(s1,s2) answer = area(s1,s2) print(f'The area is {area(s1,s2)}') result = area(side1,side2)arrow_forward
- Each cout statement has a syntax error. Type the first cout statement, and press Run to observe the error message. Fix the error, and run again. Repeat for the second, then third, cout statement.cout << "Num: " << songnum << endl; cout << int songNum << endl; cout << songNum " songs" << endl; #include <iostream>using namespace std; int main() { int songNum; songNum = 5; /* Your solution goes here */ return 0;}arrow_forwardRead the following scenario, then answer the question that follows: “An application requires a user to enter two numbers. Once the user has entered the two numbers, the application will call a module to calculate the average of the two numbers. Once the average of the two numbers have been calculated, another module will be called to determine if the average of the two numbers is greater than 75. If the average of the two numbers is greater than 75, the message ‘Congratulations, you are in the top 5’, will be displayed.” Create a flowchart for each module that will be called. The flowcharts should adequately represent the logic in the scenario provided.arrow_forwardRead the following scenario, then answer the question that follows: “An application requires a user to enter two numbers. Once the user has entered the two numbers, the application will call a module to calculate the average of the two numbers. Once the average of the two numbers have been calculated, another module will be called to determine if the average of the two numbers is greater than 75. If the average of the two numbers is greater than 75, the message ‘Congratulations, you are in the top 5’, will be displayed.” By using examples differentiate between a single‐alternative and a dual‐alternative if statement.arrow_forward
- Read the following scenario, then answer the question that follows: “An application requires a user to enter two numbers. Once the user has entered the two numbers, the application will call a module to calculate the average of the two numbers. Once the average of the two numbers have been calculated, another module will be called to determine if the average of the two numbers is greater than 75. If the average of the two numbers is greater than 75, the message ‘Congratulations, you are in the top 5’, will be displayed.” Q.3.1 Create a flowchart for each module that will be called. The flowcharts should adequately represent the logic in the scenario provided. Q.2.3 Identify the three basic structures used in a program. Also indicate which one do you prefer over others and motivate why. Q.2.4 By using examples differentiate between a single‐alternative and a dual‐alternative if statemenarrow_forwardRead the following scenario, then answer the question that follows: “An application requires a user to enter two numbers. Once the user has entered the two numbers, the application will call a module to calculate the average of the two numbers. Once the average of the two numbers have been calculated, another module will be called to determine if the average of the two numbers is greater than 75. If the average of the two numbers is greater than 75, the message ‘Congratulations, you are in the top 5’, will be displayed.” Identify the three basic structures used in a program. Also indicate which one do you prefer over others and motivate why.arrow_forwardRead the following scenario, then answer the question that follows:“An application requires a user to enter two numbers. Once the user has entered the two numbers, the application will call a module to calculate the average of the two numbers. Once the average of the two numbers have been calculated, another module will be called to determine if the average of the two numbers is greater than 75. If the average of the two numbers is greater than 75, the message ‘Congratulations, you are in the top 5’, will be displayed.”Q.3.1 Create a flowchart for each module that will be called. The flowcharts should adequately represent the logic in the scenario provided.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,