ELC 2414 Computer Programming (2) Fundamentals (1) Week Topic Quiz
26 Questions
1 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which data type is used to store a string of characters in Python?

  • dict
  • tuple
  • str (correct)
  • list
  • What is the result of $5 ext{ // }2$ in Python?

  • 3
  • 2.5
  • 2 (correct)
  • 1
  • What will be the output of the code 'print('let's test Printing')' in Python?

  • let's test
  • let's test Printing
  • Error: invalid syntax
  • SyntaxError (correct)
  • Which operator is used for exponentiation in Python?

    <p>**</p> Signup and view all the answers

    What is the result of $5 ext{ % }2$ in Python?

    <p>1</p> Signup and view all the answers

    Which data type is used to store an ordered sequence of items in Python?

    <p>list</p> Signup and view all the answers

    What will be the type of the variable 'age' if it is assigned the value of 'input()' without any conversion in Python?

    <p>'str'</p> Signup and view all the answers

    What is the type of value returned by the 'input()' function in Python?

    <p>'str'</p> Signup and view all the answers

    Which data type is used to store a list of key/value pairs in Python?

    <p>'dict'</p> Signup and view all the answers

    What will be the output of the code 'print('The sum=', 5 + 2)' in Python?

    <p>'The sum=', 7</p> Signup and view all the answers

    What is the output of the code 'print('Hello'[-1])' in Python?

    <p>o</p> Signup and view all the answers

    What is the result of the code 'print('abcde'.index('cd'))' in Python?

    <p>2</p> Signup and view all the answers

    What will be the output of the code 'print('Python'[1:4])' in Python?

    <p>yth</p> Signup and view all the answers

    How many times does the letter 'e' appear in the string 'experience'?

    <p>3</p> Signup and view all the answers

    What will be the output of the code 'print('hello'.replace('l', 'L'))' in Python?

    <p>heLLo</p> Signup and view all the answers

    What is the result of the code 'print('Python'.endswith('on'))' in Python?

    <p>True</p> Signup and view all the answers

    What will be the output of the following code?

    my_list = [1, 2, 3, 4, 5] 
    print(my_list[1:3])```
    

    <p>[2, 3]</p> Signup and view all the answers

    Which of the following best describes the 'append' method for lists in Python?

    <p>It adds an item to the end of the list.</p> Signup and view all the answers

    What will be the output of the following code?

    my_dict = {'a': 1, 'b': 2} 
    print(my_dict['c'])```
    

    <p>KeyError: 'c'</p> Signup and view all the answers

    Which of the following operations can be performed on sets in Python?

    <p>Membership testing</p> Signup and view all the answers

    What will be the output of the following code?

    s1 = {1, 2, 3} 
    s2 = {3, 4, 5} 
    print(s1.intersection(s2))```
    

    <p>{3}</p> Signup and view all the answers

    What will be the result of applying the 'remove' method on set s1 with an element that does not exist in the set?

    <p>ValueError</p> Signup and view all the answers

    What will be the output of the following code?

    degrees = {'Ahmed': 67, 'Wael': 90, 'Omar': 99, 'Anas': 80} 
    print(degrees.values())```
    

    <p>[67, 90, 99, 80]</p> Signup and view all the answers

    What will be the output of the following code?

    degrees = {'Ahmed': 67, 'Wael': 90, 'Omar': 99, 'Anas': 80} 
    degrees.pop('Wael') 
    print(degrees)
    

    Signup and view all the answers

    What will be the result of applying len() function to an empty set?

    <p>0</p> Signup and view all the answers

    What is the value of my_string if my_string = 'Hello World'[-1:]?

    <p>'d'</p> Signup and view all the answers

    More Like This

    Python Language Quiz
    3 questions

    Python Language Quiz

    SucceedingCitrine avatar
    SucceedingCitrine
    Python Language Quiz
    5 questions

    Python Language Quiz

    WittyIntelligence9198 avatar
    WittyIntelligence9198
    Python Language Mastery Quiz
    26 questions
    Use Quizgecko on...
    Browser
    Browser