WGU D522 Python for IT Automation Cram
Sheet Questions with Verified Correct Answers
print(x)
Outputs text or variables to the console.
input(prompt)
Prompts and retrieves user input as a string.
len(x)
Returns the number of items in a sequence or collection.
type(x)
Returns the data type of the specified object.
range(start, stop, step)
Generates a sequence of numbers, commonly used in loops.
enumerate(iterable)
Returns index and value pairs during iteration.
zip(a, b)
Combines multiple iterables element-wise into tuples.
sorted(iterable)
Returns a new sorted list from the items in an iterable.
sum(list)
Adds all numerical items in an iterable.
, min() and max()
Return the smallest and largest values in an iterable.
abs(x)
Returns the absolute value of a number.
round(x, n)
Rounds a number to n decimal places.
isinstance(x, type)
Checks if an object is an instance of a specified class.
hasattr(obj, name)
Checks if an object has a specified attribute or method.
str(), int(), float(), bool()
Functions used for explicit data type conversion.
dict(), list(), tuple(), set()
Constructor functions used to build or convert data structures.
.strip()
Removes whitespace from both ends of a string.
.lstrip() and .rstrip()
Remove whitespace from the left or right side of a string.
.lower() and .upper()
Convert a string to all lowercase or all uppercase.
Sheet Questions with Verified Correct Answers
print(x)
Outputs text or variables to the console.
input(prompt)
Prompts and retrieves user input as a string.
len(x)
Returns the number of items in a sequence or collection.
type(x)
Returns the data type of the specified object.
range(start, stop, step)
Generates a sequence of numbers, commonly used in loops.
enumerate(iterable)
Returns index and value pairs during iteration.
zip(a, b)
Combines multiple iterables element-wise into tuples.
sorted(iterable)
Returns a new sorted list from the items in an iterable.
sum(list)
Adds all numerical items in an iterable.
, min() and max()
Return the smallest and largest values in an iterable.
abs(x)
Returns the absolute value of a number.
round(x, n)
Rounds a number to n decimal places.
isinstance(x, type)
Checks if an object is an instance of a specified class.
hasattr(obj, name)
Checks if an object has a specified attribute or method.
str(), int(), float(), bool()
Functions used for explicit data type conversion.
dict(), list(), tuple(), set()
Constructor functions used to build or convert data structures.
.strip()
Removes whitespace from both ends of a string.
.lstrip() and .rstrip()
Remove whitespace from the left or right side of a string.
.lower() and .upper()
Convert a string to all lowercase or all uppercase.