CS 122 - Day 6 Exercises
This page lists some problems for today's class. After today, you should be able to solve these problems on your own. Problems with this color are more challenging.
Some commands are very similar between scratch and python. Here are some mappings
Scratch | Python |
say | |
change x by 1 | x = x + 1 |
if <condition> | if <condition>: |
forever | while True: |
ask "" and wait | answer = raw_input("") |
stop all | import sys sys.exit() |
wait 1 secs | import time time.sleep(1) |
Write a program to print out some simple information about yourself. It doesn't need to ask for any input, just print things
Write a program that asks the user for an amount, calculates what 15% of that is, and prints it out.
Write a program that asks the user to enter the width and height of a wall. It should calculate the area of the wall and print out the value.
Ask the user to enter a verb, a noun, and an adjective and then print out a sentence using those words as fill in the blank values to a preprogrammed sentence.
The Body Mass Index (BMI) value is a simple way of evaluating a person's height to weight ratio. Implement a BMI calculator, asking the user for their weight in pounds and their height in inches. The formula is:
BMI = (weightInPounds * 703) / (heightInInches * heightInInches)
Write a program that converts between a decimal value of feet into feet and inches. For example, 5.5 feet should be converted to 5 feet, 6 inches. Write another program that converts feet and inches to a decimal value for feet.