Editor

Strings: What Does This Print

What does this print? · Beginner · about 6 min

Read each short program and type exactly what it prints, with each printed line on its own line. If a program stops with an error, type the error's name, like TypeError.

Example

s = "dog"
print(s[0], len(s))

prints

d 3
  1. Program 1

    s = "banana"
    print(s.count("a"), s.find("n"))
  2. Program 2

    word = "Python"
    print(word[-1], word[-3:])
  3. Program 3

    s = "hello"
    s.upper()
    print(s)
  4. Program 4

    s = "cat"
    s[0] = "b"
    print(s)
  5. Program 5

    print("a,b,,c".split(","))
  6. Program 6

    print("-".join(["2026", "11", "07"]))
  7. Program 7

    text = "  hi there  "
    print(text.strip().title())
  8. Program 8

    print("abc" < "abd", "Zebra" < "apple")