Intro to Programming Python exam questions and 100% correct answers
List - correct answer A Python data type that holds an ordered collection of values, which can be of any type. This is equivalant to an "array" in many other languages. Python lists are "mutable," implying that they can be changed once created. Variables - correct answer Variables are assigned values using the '=' operator, which is not to be confused with the '==' sign used for testing equality. A variable can hold almost any type of value such as lists, dictionaries, functions. Functions - correct answer Python builds functions using the syntax: def function_name(variable): Functions can be stand-alone or can return values. Functions can also contain other functions. Strings - correct answer Strings store characters and have many built-in convenience methods that let you modify their content. The len() Function - correct answer Using len(some_object) returns the number of _top-level_ items contained in the object being queried. Length of string Print - correct answer A function to display the output of a program. Using the parenthesized version is arguably more consistent. The range() Function - correct answer The range() function returns a list of integers, the sequence of which is defined by the arguments passed to it. Used in for loops. While Loops - correct answer A While loop permits code to execute repeatedly until a certain condition is met. This is useful if the number of iterations required to complete a task is unknown prior to flow entering the loop.
Document information
- Uploaded on
- December 20, 2023
- Number of pages
- 2
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers