Strings in Python

Descripción

Coding Python Test sobre Strings in Python, creado por PathaPadha Support el 27/10/2020.
PathaPadha Support
Test por PathaPadha Support, actualizado hace más de 1 año
PathaPadha Support
Creado por PathaPadha Support hace más de 3 años
1459
0

Resumen del Recurso

Pregunta 1

Pregunta
Select the correct output of the following String operations strOne = str("pynative") strTwo = "pynative" print(strOne == strTwo) print(strOne is strTwo)
Respuesta
  • false false
  • true true
  • true false
  • false true

Pregunta 2

Pregunta
Python does not support a character type; a single character is treated as strings of length one.
Respuesta
  • True
  • False

Pregunta 3

Pregunta
Choose the correct function to get the ASCII code of a character
Respuesta
  • char(‘char’)
  • ord(‘char’)
  • ascii(‘char’)

Pregunta 4

Pregunta
Select the correct output of the following String operations str1 = 'Welcome' print (str1[:6] + ' PYnative')
Respuesta
  • Welcome PYnative
  • WelcomPYnative
  • Welcom PYnative
  • WelcomePYnative

Pregunta 5

Pregunta
What is the output of the following string operations ? str = "My salary is 7000"; print(str.isalnum())
Respuesta
  • True
  • False

Pregunta 6

Pregunta
Choose the correct function to get the character from ASCII number
Respuesta
  • ascii(‘number)
  • char(number)
  • chr(number)

Pregunta 7

Pregunta
What is the output of the following string comparison ? print("John" > "Jhon") print("Emma" < "Emm")
Respuesta
  • True False
  • False False

Pregunta 8

Pregunta
Select the correct output of the following String operations myString = "pynative" stringList = ["abc", "pynative", "xyz"] print(stringList[1] == myString) print(stringList[1] is myString)
Respuesta
  • true false
  • true true

Pregunta 9

Pregunta
Guess the correct output of the following code ? str1 = "PYnative" print(str1[1:4], str1[:5], str1[4:], str1[0:-1], str1[:-1])
Respuesta
  • PYn PYnat ive PYnativ vitanYP
  • Yna PYnat tive PYnativ vitanYP
  • Yna PYnat tive PYnativ PYnativ

Pregunta 10

Pregunta
Strings are immutable in Python, which means a string cannot be modified.
Respuesta
  • True
  • False

Pregunta 11

Pregunta
Guess the correct output of the following String operations str1 = 'Welcome ' print(str1*2)
Respuesta
  • WelcomeWelcome
  • TypeError: unsupported operand type(s) for * or pow(): ‘str’ and ‘int’
  • Welcome Welcome
  • Welcome2

Pregunta 12

Pregunta
Select the correct output of the following String operations str = "my name is James bond"; print (str.capitalize())
Respuesta
  • My Name Is James Bond
  • TypeError: unsupported operand type(s) for * or pow(): ‘str’ and ‘int’
  • My name is james bond

Pregunta 13

Pregunta
Which method should I use to convert String "welcome to the beautiful world of python" to "Welcome To The Beautiful World Of Python" ?
Respuesta
  • capitalize()
  • title()

Pregunta 14

Pregunta
Select the correct output of the following String operations str1 = "my isname isisis jameis isis bond"; sub = "is"; print(str1.count(sub, 4))
Respuesta
  • 5
  • 6
  • 7
  • 4

Pregunta 15

Pregunta
What is the output of the following code ? str1 = "My salary is 7000"; str2 = "7000" print(str1.isdigit()) print(str2.isdigit())
Respuesta
  • False True
  • False False
  • True False
Mostrar resumen completo Ocultar resumen completo

Similar

Python Quiz
karljmurphy
Think Python
tsilvo2001
Basic Python - Print Formatting
Rebecca Noel
What is Python?
Daniel Ingram
Python
54671
Know your Python!
educ8ict
Basic Python - Strings
Rebecca Noel
Study on IoT systems design
Tomasz Cieplak
Python
Kirstie Wu
OpenSource Programming
Faheem Ahmed
Basic Python - Lists
Rebecca Noel