Strings in Python

Descrição

Coding Python Quiz sobre Strings in Python, criado por PathaPadha Support em 27-10-2020.
PathaPadha Support
Quiz por PathaPadha Support, atualizado more than 1 year ago
PathaPadha Support
Criado por PathaPadha Support mais de 3 anos atrás
1459
0

Resumo de Recurso

Questão 1

Questão
Select the correct output of the following String operations strOne = str("pynative") strTwo = "pynative" print(strOne == strTwo) print(strOne is strTwo)
Responda
  • false false
  • true true
  • true false
  • false true

Questão 2

Questão
Python does not support a character type; a single character is treated as strings of length one.
Responda
  • True
  • False

Questão 3

Questão
Choose the correct function to get the ASCII code of a character
Responda
  • char(‘char’)
  • ord(‘char’)
  • ascii(‘char’)

Questão 4

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

Questão 5

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

Questão 6

Questão
Choose the correct function to get the character from ASCII number
Responda
  • ascii(‘number)
  • char(number)
  • chr(number)

Questão 7

Questão
What is the output of the following string comparison ? print("John" > "Jhon") print("Emma" < "Emm")
Responda
  • True False
  • False False

Questão 8

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

Questão 9

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

Questão 10

Questão
Strings are immutable in Python, which means a string cannot be modified.
Responda
  • True
  • False

Questão 11

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

Questão 12

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

Questão 13

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

Questão 14

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

Questão 15

Questão
What is the output of the following code ? str1 = "My salary is 7000"; str2 = "7000" print(str1.isdigit()) print(str2.isdigit())
Responda
  • False True
  • False False
  • True False

Semelhante

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