Skip to content

Latest commit

 

History

History
53 lines (42 loc) · 2.23 KB

Python_01_problemset.md

File metadata and controls

53 lines (42 loc) · 2.23 KB

Python 1 Problem Set

  1. Start up the Python Interactive Interpreter.

    • Print out "Hello New York"
    • Store your name in a variable
    • Print the contents of this variable.
  2. Working with a text editor. Use vi to write a script.

    • Make sure to include #!/usr/bin/env python3 at the top!!

    • Add code to print out, your name

       My name: Sofia
      
    • On the command line make it executable using chmod (only have to do this one time per script).

    • Run it from the command line.

    • Remember it is important to write only a bit, test, then write more.

    • If it works, ADD/COMMIT. Make a good message, like "added name to print"

    • Now add some code to print out your favorite color:

      My name: Sofia
      My favorite color: Green
      
    • Save it, and run it from the command line.

    • Now add some code to create a variable with your favorite activity. Make sure to give your variable a descriptive name.

    • Print out the variable with your favorite activity. You will need to use a comma in your print statement to print text and your variable. print("some text" , your_variable)

        My name: Sofia
        My favorite color: Green
        My favorite activity: Coding
      
    • Save it, and run it from the command line.

    • Now add some code to print out your favorite animal:

       My name: Sofia
       My favorite color: Green
       My favorite activity: Coding
       My favorite animal: Chicken
      

      Remember, write a bit, then run your code, write some more, then run again. This makes code easier to debug.

  3. Use sys.argv (make sure to import sys!!!) to retrieve your name, favorite color, favorite activity, and favorite animal from the command line. Remember to check out the example in the notes. Print all the variables in one print statement.

    • try using commas to separate your print arguments.
    • try using '+' to separate your print arguments.
  4. Make sure to keep your remote repository synced with your local repo. (ADD/COMMIT/PUSH)