55 lines
724 B
Markdown
55 lines
724 B
Markdown
# Day 2
|
||
|
||
## Exercises (Submit for Grading)
|
||
|
||
### Exercise 1 — Even / Odd
|
||
|
||
Ask for a number and print:
|
||
|
||
"Even" or "Odd"
|
||
|
||
use:
|
||
```python
|
||
n % 2
|
||
```
|
||
|
||
## Exercise 2 — Count Letters
|
||
|
||
Given a string:
|
||
|
||
count only alphabetic characters
|
||
|
||
ignore digits and symbols
|
||
|
||
## Exercise 3 — Rebuild Your C Validator (Python)
|
||
|
||
Write your own version (no copy-paste):
|
||
|
||
≤ 20 characters
|
||
|
||
starts with letter
|
||
|
||
no digits
|
||
|
||
no spaces
|
||
|
||
## Exercise 4 — Real-World Scenario
|
||
|
||
Given:
|
||
|
||
users = ["admin", "root1", "John_Doe", "Alice", "Bob42"]
|
||
|
||
Print only valid usernames.
|
||
|
||
Exercise 5 — Algorithm Explanation (Text)
|
||
|
||
Answer:
|
||
1. What happens to runtime if the list doubles in size?
|
||
|
||
2. Write the formula.
|
||
|
||
Expected:
|
||
|
||
T(n) = c × n
|
||
|
||
Explain in words. |