if Problems

Problem 1

print(“Question 1”)

Ask your partner for a number. Write if statements to determine:

  • Is the number positive

    • If true, print positive

  • Is the number negative

    • If true, print negative

  • Is the number 0

    • If true, print the number is 0

  • Is the number 13

    • If true, print the number is 13

  • Is the number -3

    • If true, print the number is -3

Problem 2

Write Python code that asks a user for what town Lakehurst Naval Base is located in. If the user enters “Toms River”, print correct.

What happens if you type “toms river” instead?

Problem 3

Write Python code that asks a user for the amount (price) of a pack of gum. What data type is the price?

If the amount is less than 1, print “I think this is a good price”. If the amount if greater than or equal to 1, print “I think this is expensive”

Problem 4

Create a variable named roblox and ask the question, “do you want to play roblox”.

You want extra credit so you play Roblox with Mr Cheng’s daughter so you make the logical choice.

If the user inputs “yes” print “good choice”. If the user inputs “no”, print “Mr Cheng’s daughter will be very disappointed”

Problem 5

She plays Work at a Pizza Place and earns 200 robux.

Create a variable called robux and assign it the value 200.

She plays for a few more hours and earns $50 for each hour she plays.

Ask the user how many hours she plays.

Add the initial amount she earned with the additional amount she made.

Print the total amount of Robux.

Problem 6

Write Python code that prints the equation of a line in slope intercept form. Write Python code that asks:

  • x1

  • x2

  • y1

  • y2

If the slope is positive, print positive slope. If the slope is negative, print negative slope. If the slope is undefined, print vertical line.

Problem 7

Ask the user, do you hear Laurel or Yanny?

If the user enters “Laurel”, print “doesn’t it sound like Yanny?”.

If the user enters “Yanny”, print “doesn’t it sound like Laurel?”

Problem 8

Ask the user to enter an abbreviation.

  • If the user enters "lol", print "laughing out loud".

  • If the user enters "rofl", print "rolling on the floor laughing".

  • If the user enters "lmk", print "let me know".

  • If the user enters "smh", print "shaking my head".

Problem 9

Ask the user, what is the net worth of Mark Zuckerberg. (do not enter commas when entering the number)

If the user enters 54500000000, print “yes and that’s a 54.5 billion”. If the user enters less than 54500000000, print “he has more money than that”. If the user enters more than 54500000000, print “that’s too little”.

Problem 10

Ask the user, who bought Minecraft for 2.5 billion dollars?

If the user enters “Microsoft”, print “correct”. If the user does not enter “Microsoft”, print “incorrect”.

Last updated