Professional Documents
Culture Documents
Coding Set 2 Answers
Coding Set 2 Answers
Coding Set 2 Answers
a) "HelloWorld"
1. a) "HelloWorld" 5. c) `str.length`
2. b) Immutable 6. b) `toUpperCase()`
3. b) `len()` 7. b) No
4. b) `my_string.startswith("Hello")` 8. a) null
5. a) "123" 9. d) `substring()`
10. a) `str.contains(substring)`
6. d) Using parentheses: (...)
11. c) 'v'
7. b) `upper()`
12. a) `startsWith()`
8. a) Python uses zero-based indexing.
13. a) `String.valueOf(intValue)`
9. a) 5
14. a) `replace()`
10. a) \n
15. b) Using the `+` operator
11. a) "HelloHelloHello"
16. b) "JAVA"
12. a) `strip()`
17. c) `str.endsWith(suffix)`
13. a) `find()`
18. b) `strip()`
14. b) Using the `concat()` method
19. c) "av"
15. a) Splits a string into a list of substrings
20. c) `indexOf()`
based on a delimiter
num = float(input("Enter a number: ")) num2 = int(input("Enter the second number: "))
if num > 0:
} else {
import java.util.Scanner;