C949 WGU - Python section Exam Retake With Questions And Answers All Correct.
Python interpreter - correct answer is a computer program that executes code written in the Python programming language interactive interpreter - correct answer is a program that allows the user to execute one line of code at a time. Is Python case sensitive? - correct answer Yes. Python is a case sensitive language. Phython Comments symbol - correct answer # this is a comment print() - correct answer function displays variables or expression values. print('Hello there') end=' ' inside of print() - correct answer keep the output of a subsequent print statement on the same line separated by a single space input() - correct answer will read text entered by the user int() function - correct answer can be used to convert that string to the integer 123 3 defining Properties of Python objects - correct answer Value Type Identity Mutability - correct answer indicates whether the object's value is allowed to be changed. id() - correct answer gives the value of an object's identity. floating-point number and floating-point literal - correct answer real number, like 98.6 and fractional part even if that fraction is 0, as in 1.0 scientific notation - correct answer 1.0e-3. The "e" stands for exponent Overflow occurs when.... - correct answer a value is too large to be stored in the memory ** is - correct answer exponent operator is **, as in x ** y module - correct answer a file containing Python code string concatenation - correct answer "New" + "York" container - correct answer construct used to group related values together and contains references to other objects instead of data. A list - correct answer is a container created by surrounding a sequence of variables or literals with brackets [ ]. list; append() - correct answer method is used to add new elements to a list. List; Elements can be removed using the..... method - correct answer pop() or remove() tuple - correct answer stores a collection of data, like a list, but is immutable - once created, the tuple's elements cannot be changed. named tuple - correct answer allows the programmer to define a new simple data type that consists of named attributes set - correct answer is an unordered collection of unique elements. Elements are unordered: Elements in the set do not have a position or index. Elements are unique: No elements in the set share the same value. Set; add() - correct answer places a new element into the set if the set does not contain an element with the provided value. Set; remove() and pop() - correct answer remove an element from the set. dictionary - correct answer is a Python container used to describe associative relationships. A dictionary is represented by the dict object type. created by using curly braces { } to surround the key:value pairs dict; key - correct answer is a term that can be located in a dictionary, such as the word "cat" in the English dictionary. (A key can be any immutable type, such as a number, string, or tuple;) dict; value - correct answer describes some data associated with a key, such as a definition. a value can be any type. This creates the entry or updates the value if its already there. When to use dictionary or list? - correct answer when unique, immutable associative relationships exist. the key:value pairs are immutable. This does not mean that dictionaries are immutable - dictionaries are mutable. A new dictionary entry is added by using brackets to specify the key. They key is unique - attempting to create a new entry with a key that already exists replaces the entire entry. dictionaries maintain no ordering of entities dict[key]= value - correct answer adds new key-value pair if it does not exist. Updates the value if the key already exists. del dict[key] - correct answer Deletes the entry dict[key]. e(another_dict) - correct answer merges dictionary dict with another_dict. if there are any entries in the second dictionary that already exist in the first, then those will be re-written in the first dictionary. - correct answer Removes all elements of dictionary (lt) - correct answer reads the value of the key from the dictionary print(('Caelan Dorris') returns: 6 (key, default()) - correct answer returns, and removes the key value from the dictionary. if that key does not exist, then the default is returned () - correct answer produces a view object that yields (key, value) tuples () - correct answer returns a view object that yields dictionary keys s() - correct answer returns a view object that yields dictionary values any() - correct answer returns true if any key in the dictionary is true in and not in operator - correct answer known as membership operators yield True or False if the left operand matches the value of an element in the right operand, which is always a container. formatted string literal, or f-string, - correct answer allows a programmer to create a string with placeholder expressions that are evaluated as the program executes. print(f'I need {num_items} please') branch - correct answer sequence of statements only executed under a certain condition. format specification - correct answer inside a replacement field allows a value's formatting in the string to be customized. name='Aiden'print(f'{name:s}') string print(f'{number:d}') decimal Slice notation - correct answer has the form my_str[start:end], which creates a new string whose value contains the characters of my_str from indices start to end -1. stride - correct answer determines how much to increment the index after reading each element. rfind(x) - correct answer Same as find(x) but searches the string in reverse, returning the last occurrence in the string. isalnum() - - correct answer Returns True if all characters in the string are lowercase or uppercase letters, or the numbers 0-9. strip() - - correct answer Returns a copy of the string with leading and trailing whitespace removed. - same as trim my_list = [1, 2, 3] - correct answer creates a list
Written for
- Institution
- WGU D335
- Course
- WGU D335
Document information
- Uploaded on
- July 3, 2024
- Number of pages
- 9
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers