Help
Contact
For teachers and institutes
Search courses, problems, tests…
A
A
>_
StemPy Lab
Courses ▾
Problems ▾
Practice ▾
Mock Tests
Classes
Community ▾
A
A
Quizzes
/
A function changes a string in a loop, but its result is not what the student expected. What does the program print?
Python Programming
Medium
High School (9–10)
Python Basics › Functions
PCEP (Python Institute)
Created by
StemPy Lab
Stuck? Show a hint
A function changes a string in a loop, but its result is not what the student expected.
def stretch(s, n): for i in range(n): s = s + s[-1] result = stretch("ab", 2) print(result)
What does the program print?
None
ab
abb
abbb
Check Answer
Log in to save
Tag someone
⚑ Report
← All Quizzes
← A function looks for the first vowel of a word. It returns from inside its loop, or after it. What does the program print?
A function pads a word with a fill character up to a given width. It is defined like this, and then one call below is run. Which calls run with no error? Choose every correct option. →
More on
Python Basics › Functions
Discussion (0)
Log in
to join the discussion.
Loading…
All questions on this topic →
Problems on this topic
A function ticket_price(age) gives the price of a museum ticket: under 5 is free (0), under 13 pays…
Medium
Same name, two variables
Medium
This program should show The total is 50. It stops with an error. Find the fault and fix it.
Medium
Which of these four programs shows something? Say it before you run each one.
Easy
All problems on this topic →