Pre-Test (Python Basic)

Beschreibung

Quiz am Pre-Test (Python Basic), erstellt von Mohammed Arif Mazumder am 02/07/2021.
Mohammed Arif Mazumder
Quiz von Mohammed Arif Mazumder, aktualisiert more than 1 year ago
Mohammed Arif Mazumder
Erstellt von Mohammed Arif Mazumder vor etwa 3 Jahre
1744
0

Zusammenfassung der Ressource

Frage 1

Frage
What is the output of the following code snippet: (You can see the picture too) if 'bar' in {'foo': 1, 'bar': 2, 'baz': 3}: print(1) print(2) if 'a' in 'qux': print(3) print(4)
Antworten
  • 1 2 3 4
  • 1 2 4
  • It doesn’t generate any output.
  • 4

Frage 2

Frage
The following if/elif/else statement will raise a KeyError exception: d = {'a': 0, 'b': 1, 'c': 0} if d['a'] > 0: print('ok') elif d['b'] > 0: print('ok') elif d['c'] > 0: print('ok') elif d['d'] > 0: print('ok') else: print('not ok')
Antworten
  • True
  • False

Frage 3

Frage
Shown below is a diagram of a simple dictionary: Which of the following is not a valid way to define this dictionary in Python:
Antworten
  • d = {'foo': 100, 'bar': 200, 'baz': 300}
  • d = { ('foo', 100), ('bar', 200), ('baz', 300) }
  • d = {} d['foo'] = 100 d['bar'] = 200 d['baz'] = 300
  • d = dict(foo=100, bar=200, baz=300)
  • d = dict([ ('foo', 100), ('bar', 200), ('baz', 300) ])

Frage 4

Frage
List a is defined as follows: a = [1, 2, 3, 4, 5] Select all of the following statements that remove the middle element 3 from a so that it equals [1, 2, 4, 5]:
Antworten
  • a[2] = []
  • del a[2]
  • a.add(3)
  • a[0:3] = []
  • a[2:2] = []

Frage 5

Frage
Which of the following would separate a string input_string on the first 2 occurences of the letter “e”?
Antworten
  • input_string.split('e', 2)
  • 'e'.split(input_string, maxsplit=2)
  • 'e'.split(input_string, 2)

Frage 6

Frage
What is the output of the following code snippet: d = {'foo': 1, 'bar': 2, 'baz': 3} while d: print(d.popitem()) print('Done.')
Antworten
  • Done.
  • foo bar baz
  • The snippet doesn’t generate any output.
  • ('baz', 3) ('bar', 2) ('foo', 1) Done.

Frage 7

Frage
The function sqrt() from the math module computes the square root of a number. Will the highlighted line of code raise an exception? x = -100 from math import sqrt x > 0 and sqrt(x)
Antworten
  • True
  • False

Frage 8

Frage
Which of the following mathematical operators can be used to concatenate strings:
Antworten
  • +
  • *
  • /
  • -

Frage 9

Frage
Suppose you have the following tuple definition: t = ('foo', 'bar', 'baz') Which of the following statements replaces the second element ('bar') with the string 'qux':
Antworten
  • It’s a trick question—tuples can’t be modified.
  • t(1) = 'qux'
  • t[1:1] = 'qux'
  • t[1] = 'qux'

Frage 10

Frage
What is value of this expression: 'a' + 'x' if '123'.isdigit() else 'y' + 'b'
Antworten
  • 'ab'
  • 'axb'
  • 'ax'
  • 'axyb'
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Öff.Recht - POR Streitigkeiten
myJurazone
Epochen und Literaturströmungen_1
barbara91
Unfallversicherung
Christine Zehnder
1 Grundlagen der Finanzbuchhaltung
Ella Wandao
13. Altklausuren - Allgemeinwissen Makro
Rafael Mentges
Sops EURO-FH B.Sc.
??? ???
Vetie Tierhygiene-Quiz 2013
Carolina Heide
Vetie Para Morphologie Entomologie
Kristin E
Vetie Geflüglekrankheiten altfragen 2020
Taissa Fraga de Almeida
Vetie: Geflügelkrankheiten Der Graupapagei
Björn Sake
Vetie Berufsrecht 2019
Mascha K.