3. Functions, Strings & Objects - 25 Questions


3. Functions, Strings & Objects

3. Functions, Strings & Objects

25 Questions
Created by Y. Daniel Liang - http://www.cs.armstrong.edu/liang/index.html
Free
In this quiz you will be tested about selection statements, which allow a program to choose when to execute certain instructions. For example, a program might choose how to proceed on the basis of the user's input. As you will be able to see, such statements make a program more versatile.
  1. What is max(3, 5, 1, 7, 4)?



    1
    3
    7
    5

    View Answer | Discuss in forum
  2. What is min(3, 5, 1, 7, 4)?



    1
    3
    5
    7

    View Answer | Discuss in forum
  3. What is round(3.52)?



    3.5
    3
    4
    5

    View Answer | Discuss in forum
  4. What is round(6.5)?



    4
    5
    6
    7

    View Answer | Discuss in forum
  5. What is math.degrees(math.pi / 2)?



    0.0
    90.0
    45.0
    30.0

    View Answer | Discuss in forum
  6. What is math.radians(30) * 6?



    0.0
    1.3434343
    3.141592653589793
    5.565656

    View Answer | Discuss in forum
  7. What is math.sin(math.pi / 6)?



    1.0
    1.3434343
    3.141592653589793
    0.5

    View Answer | Discuss in forum
  8. What is chr(ord('B')))?



    A
    B
    C
    D

    View Answer | Discuss in forum
  9. Suppose x is a char variable with a value 'b'. What will be displayed by the statement print(chr(ord(x) + 1))?



    a
    b
    c
    d

    View Answer | Discuss in forum
  10. Which of the following statement prints smith\exam1\test.txt?



    print("smith\exam1\test.txt")
    print("smith\\exam1\\test.txt")
    print("smith\"exam1\"test.txt")
    print("smith"\exam1"\test.txt")

    View Answer | Discuss in forum
  11. Suppose i is an int type variable. Which of the following statements display the character whose Unicode is stored in variable i?



    print(i)
    print(str(i))
    print(int(i))
    print(chr(i))

    View Answer | Discuss in forum
  12. The Unicode of 'a' is 97. What is the Unicode for 'c'?



    96
    97
    98
    99

    View Answer | Discuss in forum
  13. What will be displayed by print(ord('z') - ord('a'))?



    25
    26
    a
    z

    View Answer | Discuss in forum
  14. The expression "Good " + 1 + 2 + 3 evaluates to ________.



    Good123
    Good6
    Good 123
    Illegal expression

    View Answer | Discuss in forum
  15. What will be displayed by the following code?

    print("A", end = ' ')
    print("B", end = ' ')
    print("C", end = ' ')
    print("D", end = ' ')



    ABCD
    A, B, C, D
    A B C D
    A, B, C, D will be displayed on four lines

    View Answer | Discuss in forum
  16. Suppose s = "Welcome", what is type(s)?



    int
    float
    str
    String

    View Answer | Discuss in forum
  17. Suppose s is "Welcome", what is s.upper()?



    welcome
    WELCOME
    Welcome
    None of these

    View Answer | Discuss in forum
  18. Suppose s is "\t\tWelcome\n", what is s.strip()?



    \t\tWelcome\n
    \t\twelcome\n
    \t\tWELCOME\n
    Welcome

    View Answer | Discuss in forum
  19. To format a number x to 3 digits after the decimal point, use _______.



    format(x, "5.3f")
    format("5.3f", x)
    format(x, "5.4f")
    format("5.3f", x)

    View Answer | Discuss in forum
  20. Suppose x is 345.3546, what is format(x, "10.3f")? (note b represents a blank space)



    bb345.355
    bbb345.355
    bbbb345.355
    bbb345.354

    View Answer | Discuss in forum
  21. What will be displayed by the following code? ? (note ? represents a blank space)

      print(format("Welcome", "10s"), end = '#')
      print(format(111, "4d"), end = '#')
      print(format(924.656, "3.2f"))



    ???Welcome#?111#924.66
    Welcome#111#924.66
    Welcome#111#.66
    Welcome???#?111#924.66

    View Answer | Discuss in forum
  22. To set the pen size to 5 pixels, use _________.



    turtle.setSize(5)
    turtle.size(5)
    turtle.pensize(5)
    turtle.setPenSize(5)

    View Answer | Discuss in forum
  23. To undo the last turtle action, use _________.



    turtle.rollback()
    turtle.redo()
    turtle.undo()
    turtle.remove()

    View Answer | Discuss in forum
  24. To set a turtle drawing speed to 5, use _________.



    turtle.speed(5)
    turtle.setSpeed(5)
    turtle.setspeed(5)
    turtle.velocity(5)

    View Answer | Discuss in forum
  25. To draw a circle of diameter 10 with filled color red, use _________.



    turtle.circle(5, "red")
    turtle.circle(10, "red")
    turtle.dot(5, "red")
    turtle.dot(10, "red")

    View Answer | Discuss in forum