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