Problems

# count up

Problem 1

Using a while loop, print numbers from 1 to 10.

Problem 2

Ask the user what town they live in. Using a while loop, print the name of their town 4 times.

Problem 3

Using a while loop, print the powers of 2 from 202^0to292^9

Problem 4

Using a while loop, print even numbers from 0 to 100.

Problem 5

Using a while loop, print the sum of the first 100 numbers. (1 + 2 + 3 + ... + 100)

Problem 6

You work for five days. Using a while loop, ask the user how much money they make each day. Print how much money they have after five days.

Problem 7

First, ask the user for their name. Second, ask the user how many times they want to print their name. Using a while loop, print the user's name the number of times they specified.

Problem 8

Ask the user for a number. Using a while loop, print the squares from 1 to this number.

For example, if the user enters 10, you'll program will print:

Problem 9

Ask the user for two numbers, a and b. Print the sum of all the numbers between a and b (inclusive).

Problem 10

Ask the user for two numbers, a and b. Using a while loop, print the odd numbers between a and b (inclusive). How do you figure out if a number is even or odd?

Problem 11

Ask the user for two numbers, a and b. Using a while loop, print the sum of the odd numbers between a and b (inclusive).

Problem 12

You put $10,000 into a bank account that earns 5% interest per year. The interest formula is:

A=P(1+r)tA=P(1+r)^t

A=amountA=amount

P=PrincipalP=Principal

r=rater=rate(in %)

t=timet=time(in years)

a) Print the balance per year until the time in years.

b) How many years will it take for the account balance to double the original investment? Estimate this by inputting different amounts of time.

c) How many years does it take to triple?

Challenge

c) The Swiss National Bank (SNB) is charging a 0.75 percent fee on large deposits at the central bank, a cornerstone of its monetary policy since January 2015 which is aimed at weakening Switzerland’s currency.

If Swiss banks paid 970 million Swiss francs ($1 billion) in negative interest rate charges in the first six months of 2017, how much in deposits do Swiss banks have?

How many years will it take for the balance to be 0.

Last updated