Python String Operations and Methods

Python String Operations and Methods

12th Grade

100 Qs

quiz-placeholder

Similar activities

POST TEST TENTANG INFORMATIKA

POST TEST TENTANG INFORMATIKA

9th - 12th Grade

100 Qs

ASK t1 bab 1 dan 3

ASK t1 bab 1 dan 3

1st - 12th Grade

100 Qs

Uji Pengetahuan AIJ kelas 12

Uji Pengetahuan AIJ kelas 12

12th Grade

95 Qs

Quiz de Conhecimentos de Informática - UC1

Quiz de Conhecimentos de Informática - UC1

12th Grade

99 Qs

OCR Computer Science J277- 1.2 (Memory and Storage)

OCR Computer Science J277- 1.2 (Memory and Storage)

11th - 12th Grade

102 Qs

Ulangkaji  SK 2018

Ulangkaji SK 2018

10th - 12th Grade

100 Qs

SCRATCH 3.0 Semester Exam 2 Review

SCRATCH 3.0 Semester Exam 2 Review

9th - 12th Grade

100 Qs

OCR GCSE Computer Science Revision Paper 1- Saim C :D

OCR GCSE Computer Science Revision Paper 1- Saim C :D

8th - 12th Grade

98 Qs

Python String Operations and Methods

Python String Operations and Methods

Assessment

Quiz

Computers

12th Grade

Practice Problem

Medium

Created by

DHANESH ABRAHAM

Used 2+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

100 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following Python code?
s = "cbse@2024"
count = 0
for char in s:
----if char.isdigit():
--------count += 1
print(count)

3

4

5

9

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following Python code?
s = "Python"
result = ""
for i in range(len(s)):
------if i % 2 == 0:
---------result += s[i].upper()






-- - - else:
----------result += s[i].lower()

print(result)

"pYtHoN"

"PyThOn"

"PYTHON"

"pYtHon"

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following Python code?
s = "hello PYTHON"
new_s = ""
for char in s:
----if char.islower():
------new_s += char.upper()
----elif char.isupper():
------new_s += char.lower()
----else:
-------new_s += ' '
print(new_s)

"HELLO python"

"HELLO*PYTHON"

"hELLO*python"

"HELLO*python"

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of len(" Python ".strip())?

10

8

6

4

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method converts the first character of a string to uppercase and the rest to lowercase?

title()

upper()

capitalize()

casefold()

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If s = "InDiA", what will s.title() return?

"INDIA"

"india"

"InDia"

"India"

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the key difference between str.find() and str.index()?

find() searches from the end, while index() searches from the beginning.

index() returns -1 if the substring is not found, while find() raises a ValueError.

find() returns -1 if the substring is not found, while index() raises a ValueError.

There is no difference; they are aliases for the same method.

Create a free account and access millions of resources

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?