BYU logo Computer Science

To start this assignment, download this zip file.

The following guide pages cover material needed for this assignment:

Homework 4c - Program arguments

If you have a Windows computer use the guide for the Windows terminal setup to configure your system.


  • Decomposition (No functions are needed for Hello)
  • -2 points: sys.argv is used outside of if __name__ == "__main__".
  • -2 points: System arguments are not passed into other functions as arguments. See the best practices guide for an example.

1. Hello!

Write a program named that takes a name as an argument and prints “Hello {name}!”


$ python world
Hello world!
$ python CS110
Hello CS110!

2. Product

Write a program named that takes four numbers as arguments and prints their product.


$ python 1 2 3 4
$ python -1 1 -1 1

3. Big Words

Write a program named that takes a minimum word size as an argument.

The program then prompts the user for 5 words:

  • If the length of the word is less than the minimum size, print Too short.
  • Otherwise add the word to the list

After getting 5 words of sufficient size, print the words out.

Follow the prompts and formatting demonstrated in the example.


$ python 3
Word: word
Word: cat
Word: at
Too short.
Word: I
Too short.
Word: dog
Word: goat
Word: cow
- word
- cat
- dog
- goat
- cow

4. In there somewhere…

Write a program named that takes a short string as an argument.

The the program prompts the user for a guess:

  • If the guess matches the secret string, print You got it! and exit the program
  • If the secret string is a substring of the guess, print It's in there... and continue prompting guesses
  • Otherwise print Nope. and continue prompting guesses

Follow the prompts and formatting of the example.


$ python ar
Guess: dog
Guess: cougar
It's in there...
Guess: ug
Guess: gar
It's in there...
Guess: ar
You got it!


Be sure you can pass the tests before you turn in the assignment. Review the guide on using pytest if you need to review using pytest and what to do if a test fails.