Python knoledge

Beschreibung

Only a test about Python language
Alejandro Arboleda
Quiz von Alejandro Arboleda, aktualisiert more than 1 year ago
Alejandro Arboleda
Erstellt von Alejandro Arboleda vor mehr als 8 Jahre
91
0

Zusammenfassung der Ressource

Frage 1

Frage
Python was created by:

Frage 2

Frage
Which of the following expressions mutate, i.e., change, list my_list?
Antworten
  • my_list.reverse()
  • my_list.extend([10, 20])
  • my_list + [10, 20]
  • my_list.append(10)
  • another_list.extend(my_list)

Frage 3

Frage
Every class definition should include an initializer method. Is _init_ that method?
Antworten
  • True
  • False

Frage 4

Frage
We can loop over strings, too! The following incomplete function is a simple, but inefficient, way to reverse a string. What line of code needs to replace the questions marks for the code to work correctly? def reverse_string(s): """Returns the reversal of the given string.""" [blank_start]result[blank_end] = "" for char in s: result = char + result return result print reverse_string("hello")
Antworten
  • result - return

Frage 5

Frage
Imagine a game on a map. At the beginning, we might want to randomly assign each player a starting point. Which of the following expressions may we use in place of the question marks to correctly implement this functionality? import random def random_point(): """Returns a random point on a 100x100 grid.""" return (random.randrange(100), random.randrange(100)) def starting_points(players): """Returns a list of random points, one for each player.""" points = [] for player in players: point = random_point() [blank_start]points.append(point)[blank_end] return points
Antworten
  • points + point
  • points.extend(point)
  • point.append(points)
  • points.append(point)
  • points += point

Frage 6

Frage
The following function is supposed to check whether the given list of numbers is in ascending order. For example, we want is_ascending([2, 6, 9, 12, 400]) to return True, while is_ascending([4, 8, 2, 13]) should return False. def is_ascending(numbers): """Returns whether the given list of numbers is in ascending order.""" for i in [blank_start]range(len(numbers)[blank_end]): if numbers[i+1] < numbers[i]: [blank_start]return False[blank_end] return True However, the function doesn't quite work. Try it on the suggested tests to verify this for yourself. The easiest fix is to make a small change to the highlighted code. What should it be replaced with?
Antworten
  • range(len(numbers)
  • range(len(numbers - 1))
  • range(1, len(numbers))
  • range(len(numbers)) - 1
  • return False
  • return false
  • return true
  • return True

Frage 7

Frage
Is the logo of...
Antworten
  • Python

Frage 8

Antworten
  • Html 5
  • Visual Studio
  • CSS 3
  • Python

Frage 9

Frage
Is the logo of...
Antworten
  • CSS 3
  • Python
  • Visual Studio
  • Html 5
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Test PYTHON
peralesmagana
test python
Jonathan Vg
Practica #1 Sublime Text
10-4 ARISTIZABAL NOREÑA YUSLY SORELY
Lenguaje de programación
fabiola flores
Objetos mutables e inmutables
Benjamin Villalpando
ANIME
Paula Olmos
Sintaxis de Python
themagoleo666 .
Programming language
JGiron
Arqutectura WS SDG
Jonathan Yaguachi
What is programming language? Why python?
51143
Ruffini con Librería Python
Luis Manuel Méndez