Input and Output Exercises

Posted on 27-01-19 in Exercises

Input and Output Questions

print("Helloworld!")  # Print out what's in the brackets

question = "Give me a random number? "
answer = input(question)  # Stores results from input in the variable answer
answer = float(answer)  # turns answer into a float

print(answer)  # Prints out contents of answer
  1. Print out your name.

  2. Create a variable called fruit storing your favourite fruit. Print this variable out.

  3. Create two variables a and b. Print out them added together.

  4. Ask the user for their name. Print out their name.

  5. Ask the user for an integer (round number). Print out 20 subtract this number.

  6. Ask user for two numbers (floats). Tell user which one is bigger.

  7. Ask user for two numbers. Print out the first divided by the second.

  8. Ask user for a number. Tell the user if it's positive or negative.

  9. Ask user for a number. Tell the user whether it's even or odd.

  10. Tell the student their grade :

    1. Ask student for a number between 0 and 100.
    2. Tell use they score an A* if it's above 90
    3. Tell use they score an A if it's above 80
    4. Tell use they score an B if it's above 70
    5. Tell use they score an C if it's above 60
    6. Tell use they score an D if it's above 50
    7. else an F.
    8. tell student > 100 is not allowed.
  11. Ask user for five numbers. Print out the sum of these numbers.

  12. Many number calculator

    1. Ask user for how many numbers they would like to enter.
    2. Ask user for each number and store it.
    3. print out the min, max and sum of the numbers entered.
  13. Tell user whether a sphere will float or sink.

    1. Ask user for the radius of a sphere. Calculate the volume
    2. Ask user for the mass of a sphere. Calculate the density of the sphere.
    3. If density is less than water it will float else sink. (density of water is $1000kg/m3$)