Question: Write Python code that does the following: Assigns the values 3, 4 and 5 to the variables a, b and c, respectively. Write an if

  1. Write Python code that does the following:
    1. Assigns the values 3, 4 and 5 to the variables a, b and c, respectively.
    2. Write an if statement that prints OK if a is less than b
    3. Write an if statement that prints OK if c is less than b
    4. Write an if statement that prints OK if the sum of a and b is equal to c
    5. Write an if statement that prints OK if the sum of a squared and b squared equals c squared.

MY CODE:

a,b,c=3,4,5

if a

if c

if a + b == c: print('OK')

if a * a + b * b == c * c: print('OK')

2. Repeat the previous problem with the additional requirement that NOT OK is printed if the condition is false. (USE THE CODE ABOVE)

3. Write a program that asks the user for a color, a line width, a line length and a shape. Assume that the user will specify a shape that is either a line, a triangle, or a square. Use turtle graphics to draw the shape that the user requests of the size, color, line width and line length that the user requests. For example, if these are the user choices for color, width, line length and shape, the blue triangle below would be correct graphical output.

  1. line width? 25 line length? 100 line, triangle or square? triangle
  2.  Write Python code that does the following: Assigns the values 3,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!