WorksheetsStrings in Swift
Total questions: 10
Worksheet time: 5mins
Which property of the string is used get number of characters?
length
length()
count
count()
which method/methods is/are used to find the substrings in a given string?
hasPrefix()
contains()
prefix(n)
getChars(n)
We can have an empty character
True
False
let name = "Ethan Hunt"
print(name.first)
output is ?
E
Ethan
optional(E)
compiler error
let pokemon = "poke\u{0301}mon"
print(Pokemon.count)
output is ?
7
8
14
none
let kid = "Miles Morales"
print(kid[kid.index(kid.startIndex, offsetBy:3)]
output is ?
e
Optional(e)
l
optional(l)
let scarlet = "Wanda Maximoff"
print(scarlet.substring(to:scarlet.firstIndex(of:" ")!)
output is :
Wanda
W
Maximoff
Compiler Error
let strt1 = "liril"
let str2 = str1.reversed()
if str1 == str2 {
print("palindrome")
} else {
print("not a palindrome")
}
not a palindrome
palindrome
compiler error
What is the output of ?
let name = "TESSERACT"
print(name.min()!)
optional(A)
A
tesseract
compiler error
let a = 10
let b = 20
let c = 30
let result = "Solve for c. 30 = \(a)x + \(b)"
output is ?
Solve for 30. 30 = 10x + 20
Solve for c. 30 = 10x + 20
Solve for c. 30 = \1030 + 20
error
