Python Classroom
  • Introduction
  • About Python Classroom
  • Python Cloud Options
    • CS50 IDE
      • CS50 IDE Overview
      • CS50 IDE and Python
      • CS50 IDE Debugging
      • CS50 IDE Shortcuts
      • Linux Bash Shell
      • Vim Mode
        • Vim Tutorial
    • CS50 Sandbox
    • PythonAnywhere
    • Repl.it
  • Python Curriculum Map
    • Pedagogy
      • Python Professional Development
      • Teaching Tips
      • Assessment Tips
      • Rubrics
      • Activities
        • Picture Activity
        • Map Activity
        • Crossing the Bridge
        • NIM
        • Mastermind
        • Cards
          • Card Deck Algorithms
          • Sorting Cards
        • River Crossing
          • Jealous Boyfriends
          • Cannibals and Priests
          • Family
          • Police and the Thief
          • Humans and Monkeys
          • Moving Money
        • Crossing the River
        • Traveling Salesperson
        • Logic Problems
        • CIA Crack the Code
        • IQ Test
        • Puzzles
    • AP Computer Science Principles Framework
  • Python Philosphy
    • How to Practice Python
  • microbit
  • Turtle Graphics
    • Turtle Examples
    • Turtle Activities
    • Turtle Maze Problems
    • Turtle Graphics with loops
    • Turtle Snake
    • Turtle Graphics with Conditionals
  • Output
    • Output Examples
    • Output Mistakes
  • Variables
    • Variable Data Type Examples
    • Variable Role Examples
    • Variables Mistakes
    • Variables Problems
  • Math
    • Math Examples
    • Math Mistakes
    • Math Problems
    • Math Self Check
  • Input
    • Input Examples
    • Input Mistakes
    • Input Problems
  • Decisions
    • if
      • if Examples
      • if Mistakes
      • if Problems
    • if else
      • if else Examples
      • if else Problems
      • if / if else Problems
    • if elif else
      • if elif else Examples
      • if elif else Problems
    • nested if
      • nested if Examples
      • nested if Problems
    • Logical Operators
      • Logical Operators Examples
    • Adventure Game Project
  • Loops
    • while loop - count up
      • Examples
      • Problems
    • while loop - countdown
      • Examples
      • Problems
    • while loop - sentinel value
      • Problems
    • while loop - sentinel menu
      • Problems
    • for loop - range (one argument)
      • Examples
      • Problems
    • for loop - range (two arguments)
      • Problems
    • for loop - range (three arguments)
      • Problems
  • Lists
    • Lists - Numbers
      • Problems
    • Lists - Strings
      • Problems
      • Shopping Project
  • Dictionaries
  • String Methods
  • Functions
    • Variable Scope
    • Functions - no parameters
    • Functions - one parameter
    • Functions - return
    • Functions - lists
  • Files
  • Classes
    • Inheritance
  • Python Projects
    • Adventure Game
    • Restaurant Project
    • Trivia Game
    • Family Tree Project
  • Raspberry Pi
    • Raspberry Pi Models
    • Raspberry Pi Setup
  • Roblox
  • Glossary
Powered by GitBook
On this page
  • Problem 1
  • Problem 2
  • Problem 3
  • Problem 4
  • Problem 5
  • Problem 6
  • Problem 7
  • Problem 8
  • Problem 9
  • Problem 10
  • Problem 11
  • Problem 12
  • Challenge

Was this helpful?

  1. Loops
  2. while loop - count up

Problems

# count up

PreviousExamplesNextwhile loop - countdown

Last updated 5 years ago

Was this helpful?

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^020to292^929

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)^tA=P(1+r)t

A=amountA=amountA=amount

P=PrincipalP=PrincipalP=Principal

r=rater=rater=rate(in %)

t=timet=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.