0% found this document useful (0 votes)
4 views

CSS12L_Wk2_MP - Data Types (String Operators)

The document outlines two sets of programming exercises focused on string manipulation and validation, with Set A meeting expectations and Set B exceeding them. Set A includes tasks like formatting full names, counting characters in sentences, and validating email addresses, while Set B features more advanced tasks such as palindrome detection and smart email analysis. Each exercise specifies required skills and provides sample outputs for clarity.

Uploaded by

nebranmichael26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

CSS12L_Wk2_MP - Data Types (String Operators)

The document outlines two sets of programming exercises focused on string manipulation and validation, with Set A meeting expectations and Set B exceeding them. Set A includes tasks like formatting full names, counting characters in sentences, and validating email addresses, while Set B features more advanced tasks such as palindrome detection and smart email analysis. Each exercise specifies required skills and provides sample outputs for clarity.

Uploaded by

nebranmichael26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SET A (MEETS EXPECTATIONS | AVERAGE) SET B (EXCEEDS EXPECTATIONS | EXCELLENT)

Week #2 – Data Types: Strings, Operators


1. Full Name Formatter 1. Full Name Super Formatter
• Ask for the first name and last name, then • Ask for first name, middle name, and last name.
display the full name in the format: "Last Format the output as: Last Name, First Name M.
Name, First Name". (with proper capitalization).
• Skills: String concatenation, string formatting • Skills: String concatenation, string slicing,
.capitalize(), .strip(), formatted strings
• Sample Output:
Enter your first name: • Sample Output:
Marcus Enter your first name:
Enter your last name: aNNa
De Jesus Enter your middle name:
mARie
Full name: De Jesus, Marcus Enter your last name:
Reyes
2. Word Repeater
• Ask for a word and a number, then repeat Formatted Name: Reyes, Anna M.
the word that many times in one line.
• Skills: String multiplication (*), input 2. Word Pyramid
conversion • Ask for a word and an integer N. Print the word in
a growing pyramid pattern up to N times.
• Sample Output: • Skills: String multiplication, loops
Enter a word:
Hello • Sample Output:
Enter a number: Enter a word:
3 Hi
Enter a number:
Result: HelloHelloHello 4

3. Sentence Length Checker Output:


• Ask for a sentence, then display the number Hi
of characters in it (including spaces). HiHi
• Skills: len() function HiHiHi
HiHiHiHi
• Sample Output:
Enter a sentence: 3. Sentence Analyzer
Python is fun! • Ask for a sentence and return:
– Total characters
Character count: 14 – Total words
– Total vowels
4. First and Last Character • Skills: len(), .split(), string iteration, conditionals
• Ask for a word, then display its first and last
character. • Sample Output:
• Skills: Indexing ([0], [-1]) Enter a sentence:
• Sample Output: I love programming in Python.
Enter a word:
Notebook Characters: 31
Words: 5
First character: N Vowels: 9
Last character: k
SET A (MEETS EXPECTATIONS | AVERAGE) SET B (EXCEEDS EXPECTATIONS | EXCELLENT)

5. Uppercase Echo 4. Palindrome Detector


• Ask for a string, then print it in all uppercase. • Ask for a word and check if it's a palindrome (same
• Skills: String methods (.upper()) forward and backward).
• Skills: String indexing, slicing ([::-1]), Boolean logic
• Sample Output:
Enter a message: • Sample Output:
good morning Enter a word:
In uppercase: GOOD MORNING racecar
The word is a palindrome!
6. Machine Problem #2: Email Validator and
Username Formatter 5. Shout Backwards
• Ask the user to input an email address. • Ask for a phrase and display it in uppercase and
• Check if the email contains both @ and . reversed.
(basic validity). • Skills: .upper(), slicing
• If valid:
– Extract the username (text before @) • Sample Output:
– Convert it to lowercase Enter a phrase:
– Replace any . or _ with spaces to make it hello world
user-friendly Output: DLROW OLLEH
• If not valid, show an error message.
• Skills: 6. Machine Problem #2 (Advanced): Smart Email Analyzer
– .find(), .lower(), .replace(), slicing • Ask the user to input an email address.
– Conditional logic
• Check for:
– Basic string validation
– Exactly one @ symbol
– A domain that ends in .com, .edu, or .org
• Sample Output 1 (Valid Email):
– No spaces
Enter your email address:
[email protected] • If valid:
Your username is: maria santos23 – Extract the username and the domain
– Convert the username to lowercase
– Replace any _ or . in the username with spaces
• Sample Output 2 (Invalid Email):
– Display a formatted message like:
Enter your email address:
"Username: maria santos | Domain: school.edu"
maria.santos23
Invalid email address. Please include "@" • If invalid, show specific error messages depending
and a dot (.) on what failed (e.g., missing @, invalid domain,
contains space)
• Skills:
– str.count(), str.endswith(), str.find(),
str.replace(), slicing
– Conditional logic with multiple checks
– Advanced string formatting and validation

• Sample Output 1 (Valid Email):


Enter your email address:
[email protected]
Username: maria santos23
Domain: school.edu

• Sample Output 2 (Invalid - no @):


Enter your email address:
mariaschool.edu
Invalid email: missing '@' symbol.
SET A (MEETS EXPECTATIONS | AVERAGE) SET B (EXCEEDS EXPECTATIONS | EXCELLENT)

• Sample Output 3 (Invalid - bad domain):


Enter your email address:
[email protected]
Invalid email: domain must end with .com, .edu, or
.org.

You might also like