Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 1.39 KB

2-variables.md

File metadata and controls

55 lines (38 loc) · 1.39 KB

📕 Variables 🌟

The code for this exercise can be found in exercises/2-variables/.

You can manually run your code by clicking the play button, or:

$ cd ~/Desktop/2024-autumn-python-intro/exercises/2-variables
$ python3 {FILE_NAME}.py

Task 2.1: Guess the sum

Task file: guess_sum.py

Have a look at the code, and see if you can work guess what the function will print out! Then uncomment the print statement, and check if you were right :)

Expected output:

$ python3 guess_sum.py

{mysterious number}

Task 2.2: Cone Volume

Task file: cone_volume.py

You are given two variables 'radius' and 'height' which are radius and height of a cone. Using the formula ( Pi* r^2 *h)/3, can you find the volume of the cone? Print the height, radius and volume, rounded to the nearest whole number.

Hint: Do you remember what data type we use for decimals?

Expected output:

$ python3 cone_volume.py

Radius of the cone = 3
Height of the cone = 6
56.55

Task 2.3: Ramen, yummmmm!

Task file: ramen_yum.py

Write a program that determines how many bowls of ramen a restaurant can make from the given sheets of seaweed. A bowl of ramen must have 3 sheets of seaweed, no more, no less!

Your output can look like this:

$ python3 ramen_yum.py

How many sheets of seaweed: 7
The number of ramen: 2

Hint: Do you remember how to get a whole number while dividing?