About this Study Set
This study set covers Computer Science through
41 practice questions.
This content explores various functions and operators for manipulating strings in Python, including length calculation, substring extraction, case conversion, and checking for numeric values. It also delves into character encoding with ASCII and Unicode, and their corresponding Python functions (ord() and chr()). Every question includes the correct answer so you can learn as you go — pick any format above to get started.
Questions & Answers
Browse all 41 questions from the
Python String Manipulation and Character Encoding study set below.
Each question shows the correct answer — select a study format above to practice interactively.
1
Which function returns the number of characters in a string 'ch'?
-
A
Pos(ch1, ch2)
-
B
Convch(x)
-
C
Valeur (ch)
-
D
Long(ch)
2
What does the Pos(ch1, ch2) function return if ch1 is not found in ch2?
-
A
The position of ch1
-
B
0
-
C
-1
-
D
An error message
3
The Convch(x) function converts what type of input to what type of output?
-
A
String to integer
-
B
Integer to string
-
C
Float to string
-
D
String to float
4
Which function checks if a string 'ch' can be converted to a numeric value?
-
A
Estnum(ch)
-
B
Sous_chaine(ch, d, f)
-
C
Effacer(ch, d, f)
-
D
Majus(ch)
5
What does the Sous_chaî ne(ch, d, f) function return?
-
A
The string 'ch' with characters from d to f removed
-
B
A part of the string 'ch' from position d up to position f
-
C
The entire string 'ch'
-
D
The length of the string 'ch'
6
The Effacer(ch, d, f) function removes characters from position d to position f, inclusive.
7
Which function converts a string to uppercase?
-
A
Majus(ch)
-
B
len(ch)
-
C
ch2.find(ch1)
-
D
str(X)
8
In Python, what is the equivalent of the algorithmic function Long(ch)?
-
A
len(ch)
-
B
ch.length()
-
C
ch.size()
-
D
ch.count()
9
How do you find the first position of ch1 within ch2 in Python?
-
A
ch2.find(ch1)
-
B
ch1.find(ch2)
-
C
ch2.index(ch1)
-
D
ch1.index(ch2)
10
The int() function in Python converts a value to what data type?
-
A
String
-
B
Float
-
C
Integer
-
D
Boolean
11
The float() function in Python converts a value to what data type?
-
A
String
-
B
Float
-
C
Integer
-
D
Boolean
12
What does the isdecimal() method of a string return?
-
A
True if the string contains only decimal characters, False otherwise
-
B
True if the string contains only alphabetic characters, False otherwise
-
C
True if the string contains only alphanumeric characters, False otherwise
-
D
The decimal representation of the string
13
What is the result of Sous_chaî ne("bonjour", 3, 6) in algorithmic terms?
14
What is the result of Effacer("bonjour", 3, 7) in algorithmic terms?
15
What is the result of Majus("Ecole-PRIM2")?
-
A
ECOLE-PRIM2
-
B
ecole-prim2
-
C
Ecole-Prim2
-
D
EcoLe-PriM2
16
A string with zero characters is called a:
-
A
Empty string
-
B
Null string
-
C
Void string
-
D
Character array
17
What is the output of print("1a2B?".upper())?
-
A
1A2B?
-
B
1a2b?
-
C
1A2B
-
D
1a2B
18
What is the output of print(chr(65))?
19
What is the output of print(chr(97))?
20
What is the output of print(ord("A"))?
21
What is the output of print(ord("a"))?
22
What is the result of "a" + "b" in Python?
23
What is the result of "a" * 3 in Python?
24
Which operator checks for membership in Python?
25
What is the output of print(len("Hello world"))?
-
A
11
-
B
10
-
C
12
-
D
Hello world
26
What is the output of ch="m&m's".upper() followed by print(ch)?
-
A
M&M'S
-
B
m&m's
-
C
M&MS
-
D
m&ms
27
What is the result of ch1.isdecimal() if ch1="56.23"?
-
A
True
-
B
False
-
C
Error
-
D
None
28
What is the result of ch2.isdecimal() if ch2="5623"?
-
A
True
-
B
False
-
C
Error
-
D
None
29
What is the output of N=int("256")?
-
A
256 (integer)
-
B
256.0 (float)
-
C
"256" (string)
-
D
Error
30
What is the output of X=float("256")?
-
A
256 (integer)
-
B
256.0 (float)
-
C
"256" (string)
-
D
Error
31
What is the result of ch[0:3] if ch="Welcome"?
32
What is the result of ch[:2] if ch="Welcome"?
33
What is the result of ch[3:] if ch="Welcome"?
34
What is the result of ch[3:len(ch)] if ch="Welcome"?
35
What is the result of ch[3:4] if ch="Welcome"?
36
In Python, strings are immutable.
37
Which function returns the ASCII code of a character 'c'?
-
A
Chr(n)
-
B
Ord(c)
-
C
Asc(c)
-
D
Code(c)
38
Which function returns the character whose ASCII code is 'n'?
-
A
Chr(n)
-
B
Ord(c)
-
C
Asc(n)
-
D
Char(n)
39
What is the difference in ASCII codes between uppercase and lowercase letters in English?
-
A
32
-
B
1
-
C
26
-
D
Depends on the letter
40
What is the output of print("Scolaire".find("s"))?
41
What is the output of print("45, 17".isdecimal())?
-
A
True
-
B
False
-
C
Error
-
D
None