• ¿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 5 páginas
Examen

C859 Python Test Questions and Complete Solutions Graded A+

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

C859 Python Test Questions and Complete Solutions Graded A+ f1 = open("/my_path/my_", "r") - Answer: to open and read a file f1 = open("/my_path/my_", "w") - Answer: to open and write a file (all previous material discarded) f1 = open("/my_path/my_", "a") - Answer: to open and add to a file () - Answer: read a file into a string ("hello!") - Answer: writes to a file ine() - Answer: reads next line () - Answer: closes a file (must always close a file!) with open("/my_file...etc) as f: - Answer: opens, allows work, and automatically closes a file timedelta - Answer: time library function to calculate time amounts from datetime import timedelta - Answer: grabs timedelta from the datetime library import datetime as dt - Answer: imports a library as a specified variable ().month - Answer: to print current month (aka .day or .year for those) beautiful soup - Answer: HTML parsing library NumPy - Answer: scientific computing, matrices, array creation library pandas - Answer: data manipulation and analysis library pillow (PIL) - Answer: work with and manipulate images; python imaging library pyglet - Answer: multimedia / gaming creation library pytz - Answer: time zone data library pip install ____________ import _______________ - Answer: to install and import a library into your code () - Answer: round down (4.5 = 4, 4.8 = 4, 4.1 = 4, 4.9 = 4) () - Answer: round up (4.6 = 5, 4.7 = 5, 4.1 = 5, 4.2 = 5) () - Answer: get today's date .(1967, 9, 7) print(ime("%A")) - Answer: gets the day of the week rial() - Answer: multiplies each number in argument to give answer () - Answer: return e raised to power of (x) (natural log) () - Answer: return square root of x () - Answer: create a hard link pointing to a source d() - Answer: returns string of current working directory t() - Answer: change the root directory of current process path e() - Answer: remove/delete the file path () - Answer: remove/delete a directory ange(start,stop, step) - any or all arguments - Answer: return a randomly selected element nt(a,b) - Answer: return a random integer greater than a, less than b m() - Answer: return next random floating point; range 0.0 to 1.0 e(seq) - Answer: seq = list; return a random element from the list import t - Answer: generates many kinds of plots quickly; works like MATLAB PIL.() - Answer: opens up an image PIL.() - Answer: creates new image PIL.() - Answer: displays image for debugging PIL.() - Answer: saves an image in a given filename ibe() - Answer: generates descriptive statistics, stats summary s() - Answer: dataframe; 2 dimensional labeled data structure slicing (with 9 elements, grabbing the first 3) - Answer: my_list[:3] upper bound is exclusive slicing(with 9 elements, grabbing the last 3) - Answer: my_list[6:] lower bound is inclusive slicing(with 9 elements, grabbing middle 3) - Answer: my_list[3:6] () - Answer: counts how many times that item appears e() - Answer: removes item in a list; example - (0) removes 1st element se() - Answer: reverses the items in a list () - Answer: removes last item in list (3) - Answer: removes 4th item in list (str or int) - Answer: finds that specific item in list and returns it's index () - Answer: removes a random element since set are not in any specific order tuple syntax - Answer: dimensions = 50, 40, 20 formating - Answer: print("The ages are {}, {}, and {}.".format(age1, age2, age3)) syntax to add element to a set - Answer: ("item") syntax to add element to the end of a list - Answer: d("item") syntax to add element to a specific spot in a list - Answer: t(index, "item") syntax to create a dictionary - Answer: mydictionary = {"Elise": 67, "Carlos":66, "Jacquie":92} syntax to get a specific value in a dictionary - Answer: ("Elise) will return 67 or print(mydictionary["Elise"] will print 67

Vista previa del contenido

C859 Python Test Questions and
Complete Solutions Graded A+
f1 = open("/my_path/my_file.text", "r") - Answer: to open and read a file



f1 = open("/my_path/my_file.text", "w") - Answer: to open and write a file (all previous material
discarded)



f1 = open("/my_path/my_file.text", "a") - Answer: to open and add to a file



f1.read() - Answer: read a file into a string



f1.write("hello!") - Answer: writes to a file



f1.readline() - Answer: reads next line



f1.close() - Answer: closes a file (must always close a file!)



with open("/my_file...etc) as f: - Answer: opens, allows work, and automatically closes a file



timedelta - Answer: time library function to calculate time amounts



from datetime import timedelta - Answer: grabs timedelta from the datetime library



import datetime as dt - Answer: imports a library as a specified variable



datetime.date.today().month - Answer: to print current month (aka .day or .year for those)



beautiful soup - Answer: HTML parsing library

, NumPy - Answer: scientific computing, matrices, array creation library



pandas - Answer: data manipulation and analysis library



pillow (PIL) - Answer: work with and manipulate images; python imaging library



pyglet - Answer: multimedia / gaming creation library



pytz - Answer: time zone data library



pip install ____________ import _______________ - Answer: to install and import a library into your
code



math.ceil() - Answer: round down (4.5 = 4, 4.8 = 4, 4.1 = 4, 4.9 = 4)



math.floor() - Answer: round up (4.6 = 5, 4.7 = 5, 4.1 = 5, 4.2 = 5)



datetime.date.today() - Answer: get today's date



datetime.date.(1967, 9, 7)

print(mybday.strftime("%A")) - Answer: gets the day of the week



math.factorial() - Answer: multiplies each number in argument to give answer



math.exp() - Answer: return e raised to power of (x) (natural log)



math.sqrt() - Answer: return square root of x

Información del documento

Subido en
26 de marzo de 2025
Número de páginas
5
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$14.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