To start this assignment, download this zip file.
The following guide pages cover material needed for this assignment:
Homework 4a — Strings
1. Practice Problems
The following programs are incomplete:
count_whitespace.py
replace_digits.py
remove_punctuation.py
most_punctuation.py
keep_big_phrases.py
Complete each program by implementing the unfinished function. Follow the instructions given in the docstring.
Write additional functions as necessary. We recommend additional functions such as the following:
count_uppercase(string: str) -> int
count_punctuation(string: str) -> int
NOTE: Punctuation is both not whitespace and not alphanumeric.
2. BYU Students
Write a program that asks for a list of students.
Each student has name, hometown, and school.
When a person enters nothing for the name, the list is complete.
Then:
- Print out all the names of students from BYU in ALL CAPS.
- Print out all the names of students from other schools.
Match the prompts and formatting from the following example:
Enter a student.
Name: Eliza Snow
Hometown: Becket
School: BYU
Enter a student.
Name: George Smith
Hometown: Provo
School: UVU
Enter a student.
Name:
BYU Students:
- ELIZA SNOW
Other Students:
- George Smith
You can find starter code in students.py
.
Tests
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.
Grading
Activity | Points |
---|---|
Practice problems | 10 |
BYU Students | 10 |
Manual Grading
Refer to the Quality Code guide page for detailed explanations and examples on each of these rubric criteria.
Intent
The intent of this assignment is for you to correctly:
- use the string functions
- build strings using the filter and mapping patterns
- use for loops to iterate through lists of strings and characters in a string
Your for loops should show that you know if you are iterating through strings in a list or characters in a string.
Rubric | Points |
---|---|
Whitespace | 1 |
Naming | 1 |
Decomposition | 4 |
Intent | 4 |
Total | 10 |