






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







⩥ What are the traits of Object-Oriented Programming (OOP)? Answer: Organize code around objects, which encapsulate data and behavior. ⩥ What are the traits of Functional Programming? Answer: emphasizes the use of functions and immutable data for computation. ⩥ What are the traits of Declarative Programming? Answer: describes what the program should accomplish without specifying how to achieve it. ⩥ What are the traits of Event-Driven Programming? Answer: Reacts to events and user actions, triggering corresponding functions. ⩥ What are the traits of Logic Programming? Answer: defines a set of logical conditions and lets the system deduce solutions. ⩥ What does Python syntax refer to? Answer: The set of rules that dictate the combinations of symbols and keywords that form valid Python programs
⩥ What is the purpose of indentation in Python? Answer: To define blocks of code ⩥ Why might a programmer use comments for 'Preventing Execution'? Answer: To temporarily disable lines or blocks of code ⩥ What is the primary use of whitespace in Python? Answer: To define the structure and hierarchy of the code ⩥ What does Python use to define the scope of control flow statements and structures like functions and classes? Answer: Indentation ⩥ What is the purpose of the input() function in Python? Answer: To capture user input and store it as a string ⩥ What does the format() method do in Python? Answer: It enhances output formatting by embedding variables in strings. (although 'f' strings are easier to read) ⩥ What is the purpose of the Code Editor in a Python IDE? Answer: To provide a text editor designed for Python, offering features like syntax highlighting, code completion, and indentation. ⩥ What does this built in Python function do?: print() Answer: outputs text or variables to the console
⩥ What does this built in Python function do?: sorted() Answer: returns a sorted list from an iterable ⩥ What does this built in Python function do?: any(), all() Answer: checks if any or all elements in an iterable are true ⩥ What does this built in Python function do?: map(), filter() Answer: applies a function to elements or filters elements based on a function ⩥ What does this built in Python function do?: open(), read(), write() Answer: handles file I/O operations ⩥ What does this built in Python function do?: dir() Answer: lists the names in the current scope or attributes of an object ⩥ What does this built in Python function do?: help() Answer: provides help information about an object or Python ⩥ What is the primary characteristic of Python variables? Answer: Variables are created as soon as a value is assigned to them. ⩥ What are the 5 Variable name rules in Python? Answer: 1. can only contain letters, numbers, or an underscore.
⩥ what is a dictionary mapping type? Answer: an unordered collection of key-value pairs. my_dict = {'key':'value', 'name':'John'} ⩥ What happens when an operation is performed that involves both an int and a float in Python? Answer: the result is automatically promoted to a 'float' ⩥ What does the 'round(x, n) function do in Python? Answer: it rounds 'x' to 'n' decimal places ⩥ What are the two main escape characters? Answer: \n : new line \t : for a tab ⩥ What are the 3 components of a string slice? Answer: string [start:stop:step] · Start: the index from which the slicing begins (inclusive) · Stop: the index at which the slicing ends (exclusive) · Step (optional): The step or stride between characters. ⩥ What does the string slicing operation 'text {::-1] do where text = "Hello, Python!"? Answer: It reverses the string.
The 'step' portion of the slice is negative, indicating the stride between characters is reversed. ⩥ What does the 'strip()' method do in Python? Answer: It removes leading and trailing whitespaces from a string ⩥ what does the += operator do in Python string manipulation? Answer: It is used as a shorthand for concatenation and assignment ⩥ What are truthy and falsy values in Python? Answer: Truthy values are non-zero numbers and non-empty strings. Falsy values are zero, None, and empty strings ⩥ What is the purpose of the // operator in Python? Answer: It performs floor division operation; performs division and rounds down to the nearest whole number and discards the decimal part ⩥ What is the purpose of the modulus operation '%' in Python? Answer: It returns the remainder of the division of two numbers.
devices = ['router1', 'switch2', 'firewall3'] removed_device = devices.pop(1) This removes 'switch2' from devices since it is in index 1 position, and now it added to "removed_device. ⩥ What is a 'shallow copy' of a list in Python? Answer: A copy of the list where changes to the copied list do not affect the original list. ⩥ What is the difference between using the '+' operator and the 'extend()' method to concatenate lists in Python? Answer: The '+' operator creates a new list, while the 'extend()' method adds elements to the end of the original list. ⩥ What is a significant advantage of using tuples in Python for storing information about network devices? Answer: tuples can be used as keys in dictionaries due to their immutability. ⩥ How are items in a tuple accessed? Answer: By placing the index of the item inside square brackets [] after the tuple name ⩥