String Manipulation || Sumita Arora || Class 11 || Practical || Computer Science || Solution
P.I.P: - 5.1
| Values | Desired result | Expression | |
|---|---|---|---|
| (a) | a = "30" b = 20 c = 50 d = "12" |
20501230 | |
| (b) | b = 40 a = str(40) c = 20 d = "12" |
"40201240" | |
| (c) | a = "hello" b = 1 d = "2" c = 20 |
"1202 hello" |
| Code | Output | Verify | |
|---|---|---|---|
| (a) | a = 4 b = 2 print ("hi" * (a/2)) |
||
| (b) | name = "python" print (name.upper()) |
||
| (c) | name = "FRED" print (name.lower()) |
||
| (d) | name = "humberside" print (name [:2]) |
||
| (e) | a = "Middlebury" print (a [4:8]) print (a [8:12]) |
| Desired Output | String slice | |
|---|---|---|
| (a) | 'One an' | |
| (b) | 'd All' | |
| (c) | ‘LOVES O’ | |
| (d) | "AND " | |
| (e) | 'and LOVES' | |
| (f) | 'ALL IN One' |
| Expression | Output string | |
|---|---|---|
| (a) | truehuman [- 7 : - 3] | |
| (b) | truehuman [ - 3 :] | |
| (c) | truehuman [- 9 : - 3] | |
| (d) | truehuman [: 10] | |
| (e) | truehuman [12 :] | |
| (f) | truehuman [10 : -12] | |
| (g) | truehuman [9:] + truehuman [:9] | |
| (h) | truehuman [: 9] + truehuman [9 : ] |
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )