Python practice quiz - live🤩🤝

  1. Which is a valid variable name in Python?
    A 1_data
    B old-data
    C prince_in_$
    D _output

  2. Assuming the app_costs variable is initialized with zero, which of the following is an incorrect assignment statement in Python?
    A appcosts = appcosts + 6.99
    B appcosts + 6.99 = appcosts
    C app_costs += 6.99
    D None of the above

  3. companyName = ‘edyoda’
    print(type(companyName))
    What is the output of the above statement ?
    A <class ‘str’>
    B <class ‘int’>
    C <class ‘string’>
    D <class ‘bool’>

  4. Suppose my_list is [3, 6, 12, 24, 5, 10, 15, 20]. Which of the statements returns the following list [6, 24, 10, 20]?
    A print(my_list[1:8])
    B print(my_list[::2])
    C print(my_list[1::2])
    D print(my_list[-1:-7:-2])

  5. mylist = [1,2,3,3,4,5,5,5]
    print(set(mylist))
    What is the output of the snippet on image to the right?
    A {5: 3, 3: 2, 1: 1, 2: 1, 4: 1}
    B {1, 2, 3, 4, 5}
    C (1, 2, 3, 4, 5)
    D [1, 2, 3, 4, 5]

  6. What value is returned by a function that doesn’t have a return statement?
    A None
    B 0
    C 1
    D False

  7. What is the correct syntax to define a function in Python?
    A create myFunc():
    B define myFunc():
    C def myFunc():
    D function myFunc():

  8. A function that is defined in a class is called a . . . ?
    A method
    B function
    C module
    D nested class

  9. Which option refers to the bundling of data with the methods that operate on that data?
    A Encapsulation
    B Polymorphism
    C Abstraction
    D Inheritance

  10. What should we put instead of the question mark to make the following Boolean expression True?
    True and False or ?

    A True
    B False

Will reveal the answer soon after getting adequate response.

The answers of the above question are :-

  1. D
  2. B
  3. A
  4. C
  5. B
  6. A
  7. C
  8. A
  9. A
  10. A
3 Likes

1.d
2.b
3.a
4.c
5.b
6.a
7.c
8.a
9.a
10.a

2 Likes
  1. (D)
  2. (B)
  3. (A)
  4. (C)
  5. (B)
  6. (A)
  7. (C)
  8. (A)
  9. (A)
  10. (A)
    --------->>>>> And please reveal the answer the re quies
1 Like

1.d , 2.b, 3.a, 4.c, 5.b, 6.a , 7.c, 8.a, 9.a, 10.a

1 Like
  1. d
  2. b
  3. a
  4. c
  5. b
  6. a
  7. c
  8. a
  9. a
  10. a
1 Like
  1. d
  2. b
  3. a
  4. c
  5. b
  6. a
  7. c
  8. a
  9. a
    10.a
1 Like
  1. d
  2. b
  3. a
  4. c
  5. b
  6. a
  7. c
  8. a
  9. c
  10. b
1 Like

Answers are
1).D
2).B
3).A
4).C
5).B
6).A
7).C
8).A
9).A
10).A

1 Like

1.d
2.b
3.a
4.c
5.b
6.a
7.c
8.a
9.a
10.a

1 Like

Answers:

  1. A, 2. B, 3. A, 4. C, 5. B, 6. A, 7. C, 8. A, 9. A, 10. A
1 Like
  1. D 2. B 3. A 4. C 5. B 6. A 7. C 8. A 9. A 10. A
1 Like

1,D
2,B
3,A
4,C
5,B
6,A
7,C
8,A
9,A
10,A.
ANSWERS[quote=“dsedyoda, post:1, topic:1686, full:true”]

  1. Which is a valid variable name in Python?
    A 1_data
    B old-data
    C prince_in_$
    D _output

  2. Assuming the app_costs variable is initialized with zero, which of the following is an incorrect assignment statement in Python?
    A appcosts = appcosts + 6.99
    B appcosts + 6.99 = appcosts
    C app_costs += 6.99
    D None of the above

  3. companyName = ‘edyoda’
    print(type(companyName))
    What is the output of the above statement ?
    A <class ‘str’>
    B <class ‘int’>
    C <class ‘string’>
    D <class ‘bool’>

  4. Suppose my_list is [3, 6, 12, 24, 5, 10, 15, 20]. Which of the statements returns the following list [6, 24, 10, 20]?
    A print(my_list[1:8])
    B print(my_list[::2])
    C print(my_list[1::2])
    D print(my_list[-1:-7:-2])

  5. mylist = [1,2,3,3,4,5,5,5]
    print(set(mylist))
    What is the output of the snippet on image to the right?
    A {5: 3, 3: 2, 1: 1, 2: 1, 4: 1}
    B {1, 2, 3, 4, 5}
    C (1, 2, 3, 4, 5)
    D [1, 2, 3, 4, 5]

  6. What value is returned by a function that doesn’t have a return statement?
    A None
    B 0
    C 1
    D False

  7. What is the correct syntax to define a function in Python?
    A create myFunc():
    B define myFunc():
    C def myFunc():
    D function myFunc():

  8. A function that is defined in a class is called a . . . ?
    A method
    B function
    C module
    D nested class

  9. Which option refers to the bundling of data with the methods that operate on that data?
    A Encapsulation
    B Polymorphism
    C Abstraction
    D Inheritance

  10. What should we put instead of the question mark to make the following Boolean expression True?
    True and False or ?

    A True
    B False

Will reveal the answer soon after getting adequate response.

The answers of the above question are :-

  1. D
  2. B
  3. A
  4. C
  5. B
  6. A
  7. C
  8. A
  9. A
  10. A
    [/quote]
1 Like
  1. D ----> _output
  2. B ----> appcosts + 6.99 = appcosts
  3. A ----> <class ‘str’>
  4. C ----> print(my_list[1::2])
  5. B ----> {1, 2, 3, 4, 5}
  6. A ----> None
  7. C ----> def myFunc():
  8. A ----> method
  9. A ----> Encapsulation
  10. A ----> True
1 Like