input()function and type conversion (int(),float())- String methods:
upper(),lower(),strip(),replace(),split(),join(),count(),startswith(),endswith(),title(),capitalize() - String indexing and slicing
inoperator for stringslen()function- Conditionals:
if,elif,else - Logical operators:
and,or,not
Ask the user for their name using input(). Print the name in uppercase, lowercase, and title case.
Create a variable sentence = " the quick brown fox jumps over the lazy dog ".
- Print the sentence stripped of extra spaces
- Print the number of times the letter "o" appears
- Replace "fox" with "cat" and print the result
- Print the first 3 words using
split()and slicing
Ask the user for their age (convert to int). Print a message based on the age:
- Under 13: "You are a child."
- 13 to 17: "You are a teenager."
- 18 to 64: "You are an adult."
- 65 and above: "You are a senior."
- Negative number: "Invalid age!"
Ask the user for a username and password.
- If username is "admin" and password is "secret": print "Welcome, Admin!"
- If username is "admin" but wrong password: print "Incorrect password."
- If username is anything else: print "User not found."
Ask the user for their age (int) and whether they are a student (yes/no).
Calculate the ticket price:
- Children (under 12): $5
- Students (12 and above): $8
- Adults (18-64, not student): $15
- Seniors (65+): $10 Print the ticket price.
- Complete all tasks in
homework.py - Push your work to your GitHub repository
- Share the repository link with the instructor
python homework.py