Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What control structure are we using when we perform actions only if a specified condition exists? In a flow chart diagram, what shape represents a

  1. What control structure are we using when we perform actions only if a specified condition exists?
  1. In a flow chart diagram, what shape represents a true/false condition that must be tested
  1. What keyword is used at the beginning of a statement that checks a condition to determine whether a block of code should be executed or not?

What type of expression can result in true or false and is used for a conditional test.

  1. What is the difference between the (=) operator and the (==) operator?
  2. What type of operator checks if one value is NOT equal to another?
  3. What keyword can be used in a conditional statement to specify a block of code that should be run only if the previous condition was not met?
  4. When comparing strings, how does python determine which string is greater than another?
  5. What keyword is used to check a second potential condition following an if statement?
  6. How are statements lined up to indicate they are subject to an if statement?


Doing iffy statements

Do the python code for the following situations. I have highlighted variable names in bold.

 

  1. Print 'red' if the variable rgb is 10.
  2. Store the value of x into y if the value of z is less than 10.
  3. Set the price to 0, if the value of variable discount is more than the variable sales_price.

 

  1. If the number_of_dependents is more than 0, set withholding to 100; otherwise, set withholding to 1000.


  1. If the value of tax_paid is more than computed_tax, set refund to tax_paid minus computed_tax. Otherwise, set tax_owed to computed_tax minus tax_paid.


  1. If number_of_sides is 3, print 'It is a triangle'. Otherwise, print 'It is not a triangle'

 

Programming Exercise

For the following exercise, you can use the python files included in this assignment to do a simple program that will prompt the user to enter a number and then tell them if the number is odd or even.

It should look like so:


image.png



image.png


HINT: We can use the modulus operator to divide a value by 2 and see if it has a remainder of 1 or 0. If the remainder of a value divided by 2 is 1, then the number is odd, if the remainder is 0, then it is even.

 

Copy the python code in the section below. Copy and paste screenshots running the program to show it works properly for both even and odd numbers.

 
 
 

Enter a number: 1 Your number is odd

Step by Step Solution

3.43 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

What control structure are we using when we perform actions only if a specified condition exists We are using a conditional control structure typically implemented using if statements to perform actio... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Smith and Roberson Business Law

Authors: Richard A. Mann, Barry S. Roberts

15th Edition

1285141903, 1285141903, 9781285141909, 978-0538473637

More Books

Students also viewed these Programming questions