• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 6 páginas
Examen

C859 Python Syntax Questions with Complete Answers Graded A+.

Document preview thumbnail
Vista previa 2 fuera de 6 páginas

C859 Python Syntax Questions and Complete Solutions Graded A+ var1, var2, var3 = 1, 2, 3 - Answer: multiple variable assignment 12 - Answer: integer 1.2 - Answer: float 'twelve' - Answer: string "twelve" - Answer: string True or False - Answer: Boolean value type() - Answer: determines type of an object (integer, boolean, etc) int() - Answer: converts to integer object float() - Answer: converts to float object str() - Answer: converts to string object print() - Answer: displays a message + - Answer: addition (integer) or concatenation (string) - - Answer: subtraction ** - Answer: power of % - Answer: modulus, remainder / - Answer: division, always results in float // - Answer: division, always results in integer = - Answer: assignment operator += - Answer: reassignment operator, adds -= - Answer: reassignment operator, subtracts *= - Answer: reassignment operator, multiples /= - Answer: reassignment operator, divides - Answer: less than - Answer: greater than = - Answer: less than or equal to = - Answer: greater than or equal to == - Answer: equal to != - Answer: not equal to len() - Answer: returns length title() - Answer: capitalizes first letter of each word islower() - Answer: determines if the string consists of lowercase characters count() - Answer: totals number of times an argument is found within a predefined value format() - Answer: inserts variable data in a string def - Answer: keyword used to create functions def myfunction(): - Answer: syntax for function declaration return - Answer: defines output of a function if age 16: - Answer: creates an if statement else: - Answer: else statement, used in conjunction with if statement or if/elif statement elif age = 16 and age = 18: - Answer: elif statement, used in conjunction with if statement True and False - Answer: False: and operation will always be false unless both sides are true True or False - Answer: True: or operation will always be true unless both sides are false not(True and False) - Answer: True: Boolean not operation will produce the inverse value. myNumbers = [1, 4.8, 7, 9.2, 3, 0] - Answer: creates a list mylist[0] - Answer: accesses first element from a list mylist[-1] - Answer: accesses last element from a list mylist[1:3] - Answer: slices list including second and third element mylist[:3] - Answer: slices list beginning with first element and including through the third element. Index position 3 is not included in selection. mylist[3:] - Answer: slices list beginning with fourth element and include remainder of the list 9.2 in myNumbers - Answer: looks for a match and returns Boolean value 9.2 not in myNumbers - Answer: ensures a match does not exist in list len() - Answer: counts items in list max() - Answer: returns greatest element of list min() - Answer: returns smallest element of list sorted() - Answer: returns copy of list ordered smallest to largest sorted(listname, reverse=True) - Answer: returns copy of list ordered largest to smallest sum() - Answer: returns total sum of list values append() - Answer: adds new value to end of list pop() - Answer: removes last item from a list pop(1) - Answer: removes second item from a list join() - Answer: joins values from a list using a defined separator set() - Answer: creates a set, or a list that contains unique items add() - Answer: adds value to set discard() - Answer: removes value from set, if found for city in cities: - Answer: iterates over items within a list range() - Answer: defines a range of numbers while temp = 32: - Answer: iterates a set of commands as long as the condition remains true, stopping when the condition becomes false break - Answer: loop command that stops iteration prematurely studentGrades = { 'Orfu': 83, 'Bismark': 98, 'Igor': 72} - Answer: entries are added in key/value pairs if 'key' in dictionary: - Answer: verifies if key exists in dictionary get() - Answer: looks up value by key myPhone = (877, 435, 7948) - Answer: creates a tuple open('/my_path/my_','r') - Answer: opens a file object for reading open('/my_path/my_','w') - Answer: opens a file object for writing read() - Answer: reads data from open file close() - Answer: closes open file write() - Answer: writes to open file with open('/my_path/my_','r') as f: - Answer: opens a file, performs operations and automatically closes file import math - Answer: imports math module from collections import defaultdict - Answer: imports individual function from a module from csv import reader as scvreader - Answer: mports individual function from a module and assigns it a new name $ pip3 install pytz - Answer: install package through the command line import pytz - Answer: imports a package split() - Answer: string method used to break apart a string and return a list

Vista previa del contenido

C859 Python Syntax Questions and
Complete Solutions Graded A+
var1, var2, var3 = 1, 2, 3 - Answer: multiple variable assignment



12 - Answer: integer



1.2 - Answer: float



'twelve' - Answer: string



"twelve" - Answer: string



True or False - Answer: Boolean value



type() - Answer: determines type of an object (integer, boolean, etc)



int() - Answer: converts to integer object



float() - Answer: converts to float object



str() - Answer: converts to string object



print() - Answer: displays a message



+ - Answer: addition (integer) or concatenation (string)



- - Answer: subtraction

, ** - Answer: power of



% - Answer: modulus, remainder



/ - Answer: division, always results in float



// - Answer: division, always results in integer



= - Answer: assignment operator



+= - Answer: reassignment operator, adds



-= - Answer: reassignment operator, subtracts



*= - Answer: reassignment operator, multiples



/= - Answer: reassignment operator, divides



< - Answer: less than



> - Answer: greater than



<= - Answer: less than or equal to



>= - Answer: greater than or equal to



== - Answer: equal to

Información del documento

Subido en
26 de marzo de 2025
Número de páginas
6
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$13.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
YourExamplug
4.1
(74)
Vendido
228
Seguidores
27
Artículos
18118
Última venta
1 día hace




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes