



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!




Question: What type of programming language is Answer: An interpreted, high-level, general-purpose Question: Python? Answer: programming language. Question: What is the main advantage of Python's Answer: It emphasizes readability and expressiveness. Question: How is a Python script executed? Answer: It is executed directly by an interpreter at runtime without pre-compilation. Question: What is a key feature of Python's Answer: It is vast and augmented by a large array of third- Question: standard library? Answer: party libraries. Question: Which companies have adopted Answer: Google, Uber, Facebook, and Mozilla. Question: What command is used to print a Answer: The print() function. Question: How do you write a comment in Answer: By using the hash symbol (#) before the comment text. Question: What is a documentation string in Answer: A multiline comment written with three opening and Question: Python? Answer: closing double quotes.
Question: How do you create a string that Answer: Use the code: print('Hello ' * 5). Question: What is the purpose of the sys module Answer: To access command-line arguments passed to the Question: in Python? Answer: script. Question: What are variables in Python? Answer: References to values in memory that do not require pre-declaration of data types. Question: How are strings represented in Answer: As arrays of bytes representing unicode characters. Question: How can you check the type of a value Answer: By using the type() function. Question: What is the output of type(12) in Answer: . Question: How do you obtain user input from the Answer: Using the input() function. Question: What is the significance of indentation Answer: It is required for indicating a block of code. Question: What prefix is used for binary numbers Answer: 0b. Question: How do you convert a decimal number Answer: Using the built-in bin() function. Question: What operator is used for string Answer: The + operator. Question: What is the index of the first character Answer: 0.
Question: What does the range function do? Answer: It generates a list of numbers based on specified start, stop, and step parameters. Question: What is the purpose of the break Answer: To exit a loop based on a condition external to the Question: statement? Answer: loop. Question: What is a user-defined function? Answer: A function defined by the user to organize code into logical fragments. Question: What is the difference between local Answer: Local variables are defined inside a function and Question: and global variables? Answer: accessible only there; global variables are defined outside and accessible everywhere. Question: How do you create a dictionary in Answer: Use curly braces with key-value pairs, e.g., {'key': Question: Python? Answer: 'value'}. Question: What method retrieves both keys and Answer: The items() method. Question: What is a set in Python? Answer: An unordered collection of unique elements. Question: How do you eliminate duplicate Answer: By using a set, which automatically removes Question: entries in a collection? Answer: duplicates. Question: What does the len() function return Answer: It returns the number of items in the list.
Question: What is the syntax to define a function Answer: def function_name(parameter_one, parameter_two): Question: What does the continue statement do Answer: It skips the current iteration and continues with the Question: in a loop? Answer: next iteration of the loop. Question: How can you check if a key exists in a Answer: Using the syntax 'key in dictionary'.