Skip to content

Latest commit

 

History

History
132 lines (87 loc) · 4.14 KB

exercises.md

File metadata and controls

132 lines (87 loc) · 4.14 KB

Exercises for Students

Solutions for these exercises are in the solutions/ folder

You can't learn without practice.

001 Hello World

  • Print your name
  • Print today's date
  • Print a sentence

002 Variables

  • Make a variable called age that is set to your actual age. Then print your age using the variable age.
  • Make a variable called am_i_awesome, set it to true, and print the variable.
  • Make your own greeting and print it out.

003 Expressions

  • Calculate:

    • 72 x 234 x 12
    • Remainder of 6439 divided by 6
  • Print "twelve" 12 times (hint: you don't need to type "twelve" more than once)

  • Make a variable containing "rain" and another containing "bow" then add and print them together

  • Make greeting and name variables and then use those variables to print "Good Afternoon, [insert your name] !"

  • Print a few pictures:

face
  __  __
   *  *
    <
   |___|

house
    ^
  / O \
 /_____\      
 | X X |     
 |  U  |   
------------

duck
      __
    <(o )___
     ( ._> /
      `---'

004 Tuples and Lists

  • Make two variables:

    • pirate that equals "Yee Haw! *takes off hat and waives it around*"
    • cowboy or cowgirl that equals "Argh! Shiver me timbers!" and swap their values
  • Make a tuple of all your favorite foods. Then make a tuple of all your favorite hobbies. Combine these tuples, and call it favorites. Print them all out.

  • Make a tuple of all the TV shows or movies you've watched this year. Then figure out how many TV shows or movies you've watched (hint: you don't need to count them yourself!)

  • Now do the last 2 exercises, but using a list this time. Then remove the last item from each list, using an additional line of code.

time.py

  • Write a real compelling story, maybe with dialogue too

005 User Input

  • Ask the user for their first, middle, and last name. Print their full name.

  • Ask the user for two numbers. Print the average.

  • Ask the user for their pet name and various stats (e.g. Type? Amount of HP? Attack/Defense? Favorite toy?). In the end, print it all out in a neat fashion.

006 Decisions

  • Ask the user for two numbers. Tell the user which one is bigger or if they are both equal.

  • Ask the user how many ninjas are there. Tell the user whether or not they take 'em out or what's the probability of taking 'em out.

  • Make a text-based adventure story/game. Draw it out on a piece of paper before you begin.

  • Rock, paper, scissor, shoot!

007 Loops and Random

Make a flowchart of these before you begin to write code.

  • Ask the user if they want to roll a dice. If they say yes, roll the dice and display the side of the dice using ASCII art. If they say no, then cast them into an eternity of doom from which not even light can escape.

  • Make a fortune teller. Ask the user if they would like to hear a fortune, then give them a random fortune. Once a fortune is given, ask the user if they would like to hear another one and repeat.

  • Make a guess-the-number game. Generate the number randomly. Tell the user if they it's too high or too low after each guess.

008 & 009 Functions

Make a flowchart of these before you begin to write code.

  • Function for finding the average of numbers passed into it

  • Print the Fibonacci sequence until the Nth number where N is a number specified by the user

    • Fibonacci sequence: 1, 1, 2, 3, 5, 8, 14
  • Make hangman using functions, loops, random (for choosing a word), and user input.

    • Remember, you can print the hangman each time using a function
      • make the hangman in stick figures first

010 Turtle

Use input for customizing output from turtle Use loops for repetition Use random for colors Use functions for defining & customizing shapes

  • Draw a square, triangle, rectangle, and diamond
  • Draw an octagon & a dodecagon (12-sided-polygon)
  • Draw a Star (DrawStar.py)
  • Swiveling shapes around a point with CircleMagic (2 circles) and SquareMagic (use any shape(s))
  • Drawing Machine (DrawingMachine.py)

011 File I/O

  • Improve upon the hangman game, by pulling the words from a words.txt file instead of a list or tuple
  • Write directions for Turtle