Solved Quarter-2 Name: Revision Worksheet - 1 Grade: Date: | Chegg.com - Free Printable
Educational worksheet: Solved Quarter-2 Name: Revision Worksheet - 1 Grade: Date: | Chegg.com. Download and print for classroom or home learning activities.
JPG
611×700
33.1 KB
Free · Personal Use
Quality Assured by Worksheets Library Team
Reviewed for educational accuracy and age-appropriateness
ID: #1467683
⭐
Show Answer Key & Explanations
Step-by-step solution for: Solved Quarter-2 Name: Revision Worksheet - 1 Grade: Date: | Chegg.com
▼
Show Answer Key & Explanations
Step-by-step solution for: Solved Quarter-2 Name: Revision Worksheet - 1 Grade: Date: | Chegg.com
Let’s solve each question one by one with clear explanations.
---
Question 1:
> Let `x = "python is a high level language."`, the output of `print(x.replace("a","A"))` is
✔ Correct Answer: a. python is A high level lAnguAge.
Explanation:
- The `.replace(old, new)` method replaces all occurrences of the substring `old` with `new`.
- In the string `"python is a high level language."`, every `'a'` becomes `'A'`.
- So:
- `'a'` in `"a"` → `"A"`
- `'a'` in `"language"` → `"lAnguAge"` (the 2nd and 5th letters become 'A')
- Result: `"python is A high level lAnguAge."`
- Option a matches exactly.
---
Question 2:
> Let `x = "Python and java"`, the output of `print(len(x))` is
✔ Correct Answer: b. 15
Explanation:
- `len()` returns the number of characters in the string, including spaces.
- Count each character in `"Python and java"`:
- P y t h o n a n d j a v a
- That’s 6 (Python) + 1 (space) + 3 (and) + 1 (space) + 4 (java) = 15
- So `len(x)` = 15 → b
---
Question 3:
> Choose the correct python program that has the output 4:
✔ Correct Answer: c. print(2+2)
Explanation:
- Option a: `print(len("Java"))` → `"Java"` has 4 characters → outputs 4 ✔
- Option b: `print("2+2")` → prints the string `"2+2"` literally → outputs `2+2` ✘
- Option c: `print(2+2)` → evaluates to 4 → outputs 4 ✔
- Option d: “Both a and c” → since both a and c output 4 → this is also correct!
Wait — this is tricky. Both a and c produce output `4`.
But let’s check the options again:
> a. print(len("Java")) → 4
> b. print("2+2") → "2+2"
> c. print(2+2) → 4
> d. Both a and c → ✔
So d is the most complete correct answer.
✔ Final Answer: d. Both a and c
*(Note: Some teachers might expect only one answer, but logically, both a and c are correct. Since option d exists, it's the best choice.)*
---
Question 4:
> Let `x = "python is a high level language"`, the output of `print(x[7:])` is
✔ Correct Answer: a. is a high level language
Explanation:
- String slicing: `x[start:end]` — if `end` is omitted, it goes to the end.
- `x[7:]` means start at index 7 and go to the end.
- Indexing starts at 0:
```
p y t h o n i s a h i g h l e v e l l a n g u a g e
0 1 2 3 4 5 6 7 8 9 10 11...
```
- At index 7: `'i'` (after "python ")
- So from index 7 to end: `"is a high level language"`
→ Matches option a
---
Question 5:
> Let `x = "Hello, world"`, the output of `print(x[-12:-6])` is
✔ Correct Answer: b. Hello,
Explanation:
- Negative indices count from the end:
- `-1` is last character `'d'`
- `-2` is `'l'`
- ...
- Let’s write the string with negative indices:
```
H e l l o , w o r l d
-12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
```
Wait — let’s count properly:
String: `"Hello, world"` → 13 characters? Let’s count:
H e l l o , w o r l d
1 2 3 4 5 6 7 8 9 10 11 12 13 → Wait, no!
Actually:
`"Hello, world"` →
H e l l o , (space) w o r l d → that’s 12 characters.
Let’s list them with indices:
```
Index: 0 1 2 3 4 5 6 7 8 9 10 11
Char: H e l l o , w o r l d
Negative: -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
```
So:
- `x[-12]` = `'H'`
- `x[-6]` = space (before ‘w’)
- Slice `x[-12:-6]` → from index -12 to -6 (exclusive)
That gives us: from `'H'` up to (but not including) the space → `"Hello,"`
✔ So output is `"Hello,"` → Option b
---
## ✔ Final Answers:
1. a
2. b
3. d
4. a
5. b
Let me know if you want these explained visually or with code examples!
---
Question 1:
> Let `x = "python is a high level language."`, the output of `print(x.replace("a","A"))` is
✔ Correct Answer: a. python is A high level lAnguAge.
Explanation:
- The `.replace(old, new)` method replaces all occurrences of the substring `old` with `new`.
- In the string `"python is a high level language."`, every `'a'` becomes `'A'`.
- So:
- `'a'` in `"a"` → `"A"`
- `'a'` in `"language"` → `"lAnguAge"` (the 2nd and 5th letters become 'A')
- Result: `"python is A high level lAnguAge."`
- Option a matches exactly.
---
Question 2:
> Let `x = "Python and java"`, the output of `print(len(x))` is
✔ Correct Answer: b. 15
Explanation:
- `len()` returns the number of characters in the string, including spaces.
- Count each character in `"Python and java"`:
- P y t h o n a n d j a v a
- That’s 6 (Python) + 1 (space) + 3 (and) + 1 (space) + 4 (java) = 15
- So `len(x)` = 15 → b
---
Question 3:
> Choose the correct python program that has the output 4:
✔ Correct Answer: c. print(2+2)
Explanation:
- Option a: `print(len("Java"))` → `"Java"` has 4 characters → outputs 4 ✔
- Option b: `print("2+2")` → prints the string `"2+2"` literally → outputs `2+2` ✘
- Option c: `print(2+2)` → evaluates to 4 → outputs 4 ✔
- Option d: “Both a and c” → since both a and c output 4 → this is also correct!
Wait — this is tricky. Both a and c produce output `4`.
But let’s check the options again:
> a. print(len("Java")) → 4
> b. print("2+2") → "2+2"
> c. print(2+2) → 4
> d. Both a and c → ✔
So d is the most complete correct answer.
✔ Final Answer: d. Both a and c
*(Note: Some teachers might expect only one answer, but logically, both a and c are correct. Since option d exists, it's the best choice.)*
---
Question 4:
> Let `x = "python is a high level language"`, the output of `print(x[7:])` is
✔ Correct Answer: a. is a high level language
Explanation:
- String slicing: `x[start:end]` — if `end` is omitted, it goes to the end.
- `x[7:]` means start at index 7 and go to the end.
- Indexing starts at 0:
```
p y t h o n i s a h i g h l e v e l l a n g u a g e
0 1 2 3 4 5 6 7 8 9 10 11...
```
- At index 7: `'i'` (after "python ")
- So from index 7 to end: `"is a high level language"`
→ Matches option a
---
Question 5:
> Let `x = "Hello, world"`, the output of `print(x[-12:-6])` is
✔ Correct Answer: b. Hello,
Explanation:
- Negative indices count from the end:
- `-1` is last character `'d'`
- `-2` is `'l'`
- ...
- Let’s write the string with negative indices:
```
H e l l o , w o r l d
-12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
```
Wait — let’s count properly:
String: `"Hello, world"` → 13 characters? Let’s count:
H e l l o , w o r l d
1 2 3 4 5 6 7 8 9 10 11 12 13 → Wait, no!
Actually:
`"Hello, world"` →
H e l l o , (space) w o r l d → that’s 12 characters.
Let’s list them with indices:
```
Index: 0 1 2 3 4 5 6 7 8 9 10 11
Char: H e l l o , w o r l d
Negative: -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
```
So:
- `x[-12]` = `'H'`
- `x[-6]` = space (before ‘w’)
- Slice `x[-12:-6]` → from index -12 to -6 (exclusive)
That gives us: from `'H'` up to (but not including) the space → `"Hello,"`
✔ So output is `"Hello,"` → Option b
---
## ✔ Final Answers:
1. a
2. b
3. d
4. a
5. b
Let me know if you want these explained visually or with code examples!
Parent Tip: Review the logic above to help your child master the concept of python worksheet.