Quiz 6: Strings

0.0(0)
studied byStudied by 3 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/10

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

11 Terms

1
New cards

Consider the string new_string = 'Berlin is the capital of Germany'. What is the resulting substring? new_string[-7:]

'Germany'

# NOTE: This code was generated form Gemini AI b/c test results have not been shown for this quiz

2
New cards

If factor = 24, which format will generate ‘**24', right aligned in its field?

factor = 24

# Format:

# '*' is the fill character

# '>' means right-align

# '4' is the total field width

output = f"{factor:*>4}"

print(output)

# NOTE: This code was generated form Gemini AI b/c test results have not been shown for this quiz

3
New cards

What is the result?

my_string = 'The area postal code is 99501'

print(my_string[-8:].isdigit())

print(my_string[:4].isupper())

print(my_string[:6].islower())

False

False

False

# NOTE: This code was generated form Gemini AI b/c test results have not been shown for this quiz

4
New cards

What is output?

my_books = 'Books 105'

index = my_books.find(", 3)

print(index)

4

# NOTE: This code was generated form Gemini AI b/c test results have not been shown for this quiz

5
New cards

What is the value of new_title?

title = 'Python for Beginners'

tokens = title.split(' ')

if 'Chapter 1' not in tokens:

tokens.append('Chapter 1')

new_title = ' '.join(tokens)

‘Python for Beginners Chapter 1’

# NOTE: This code was generated form Gemini AI b/c test results have not been shown for this quiz

6
New cards

What is the output?

my_string = 'What is your name?'

print(my_string.split('?'))

['What is your name', '']

# NOTE: This code was generated form Gemini AI b/c test results have not been shown for this quiz

7
New cards

Consider the list

my_list = ['www', 'python', 'org'].

What option will return ‘www.python.org'as the value to my_string.

my_string = '.'.join(my_list)

# NOTE: This code was generated form Gemini AI b/c test results have not been shown for this quiz

8
New cards

What defines the minimum number of character that must be inserted into the string?

The Field Width (or Total Width), in relation to the Original String Length

Padding = Field Width - Original String Length

# NOTE: This code was generated form Gemini AI b/c test results have not been shown for this quiz

9
New cards

What is the output?

my_poem = 'Roses are red; Violets are blue'

new_separator = '-'

new_poem = my_poem.split(';')

print(new_separator.join(new_poem))

Roses are red- Violets are blue

# NOTE: This code was generated form Gemini AI b/c test results have not been shown for this quiz

10
New cards

What is the output?

my_string = 'Greetings!'

print(my_string == 'greetings!')

print('tin' in my_string)

print('Hello' > my_string)

False

True

True

# NOTE: This code was generated form Gemini AI b/c test results have not been shown for this quiz

11
New cards

What is the output?

new_string = 'One giant leap for mankind'

print(new_string[0:6])

One gi

# NOTE: This code was generated form Gemini AI b/c test results have not been shown for this quiz