Strings in Python

Beschreibung

Coding Python Quiz am Strings in Python, erstellt von PathaPadha Support am 27/10/2020.
PathaPadha Support
Quiz von PathaPadha Support, aktualisiert more than 1 year ago
PathaPadha Support
Erstellt von PathaPadha Support vor etwa 4 Jahre
1472
0

Zusammenfassung der Ressource

Frage 1

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

Frage 2

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

Frage 3

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

Frage 4

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

Frage 5

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

Frage 6

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

Frage 7

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

Frage 8

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

Frage 9

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

Frage 10

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

Frage 11

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

Frage 12

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

Frage 13

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

Frage 14

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

Frage 15

Frage
What is the output of the following code ? str1 = "My salary is 7000"; str2 = "7000" print(str1.isdigit()) print(str2.isdigit())
Antworten
  • False True
  • False False
  • True False
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

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