





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This python coding study guide covers a wide range of topics, including basic data types, operators, control structures, functions, and more. It provides sample code snippets and explanations to help students understand the fundamental concepts of python programming. The guide is designed to prepare students for a final exam, covering topics such as string manipulation, list operations, conditional statements, loops, and recursion. By studying this document, students can gain a solid understanding of python syntax, logic, and problem-solving techniques, which are essential for success in python-based programming courses or projects.
Typology: Exams
1 / 9
This page cannot be seen from the preview
Don't miss anything!






What will be the result of the following Python 3 statement? temperature = "3" + "5" - correct answer ✔✔' 35 ' What will be the output of the following code in Python 3? number = 6 number = number + 4 lucky_number = 10 * number print(lucky_number/number) - correct answer ✔✔ 10 What is the output of the following code in Python 3? print("Ozymandius"[2:4]) - correct answer ✔✔ym What is the output of the following code in Python 3? print(5>= 5) - correct answer ✔✔True What is the output of the following code in Python 3? animals = ["mammal","reptile","insect","fish"] animals.insert(3,"bird") print(animals) - correct answer ✔✔['mammal','reptile','insect','bird','fish'] What is the output of the following code in Python 3?
print(17%5) - correct answer ✔✔ 2 Which of the following Python 3 instructions will produce the output Hello World? Print("Hello World") print "Hello World" print "Hello World" print("Hello World") - correct answer ✔✔print("Hello World") What character(s) is used at the start of a line in Python to indicate that what follows should be treated as a comment? - correct answer ✔✔# Which of the following is a type in Python? int bool list All of the above - correct answer ✔✔All of the above A fragment of code that causes a data type to be evaluated? - correct answer ✔✔Expression A single unit of code that the Python interpreter can execute? - correct answer ✔✔Statement What is the output of the following code in Python 3? print(1 and 0) - correct answer ✔✔ 0 If we have just 1 + 1 what are the outcome in command prompt (Shell Mode) and script? - correct answer ✔✔2 and blank
Items in a dictionary are... - correct answer ✔✔unordered so they cannot be referenced using their ordinal position...the actual order of the items is unpredictable. What results from "3" + "5"? Why? - correct answer ✔✔' 35'. Because they are surrounded by quotation marks, the interpreter treats the values as letters and concatenates them. What is 6 + 10 / 2? What is it called when calculation is correct but not meant for this result? - correct answer ✔✔11. Semantically Incorrect. Consider the following: lucky_number = 42 print(lucky_number) 42 What is lucky_number in this case? - correct answer ✔✔A variable: gives a name to a value. Consider the following: lucky_number = lucky_number * 2 print(lucky_number) 84 What happened? - correct answer ✔✔Assigned value of lucky_number * 2 to variable lucky_number. This changes the value of the variable lucky_number. Variable names are case sensitive. Single unit of code that the Python interpreter can execute - correct answer ✔✔Statement Any fragment of code that causes a data type to be evaluated - correct answer ✔✔Expression
What are the different types in Python? - correct answer ✔✔Integer, Floating Point Number, String, Boolean, List Data type for text and contained within quotation marks - correct answer ✔✔String; can consist of: Letters (both uppercase and lowercase); numbers; special characters; spaces; or combo of above What is the difference/similarities between string and list - correct answer ✔✔String data types consist of a sequence of characters. They are similar to the list data type. The main difference between the two is that a list can contain any data type, while string can only contain characters. Declared by assigning a sequence of values between square brackets to a variable. - correct answer ✔✔List. Values in a list can be of any data type including integers, strings, or a mix of data types including other lists. Operators - correct answer ✔✔Special symbols that represent operations that can be performed on data. Each data type supports a set of operations. Some are supported by multiple different data types, but the results of the operation may differ. greeting = "hello world" greeting[2:4] - correct answer ✔✔ll vegetable = ["tree", "flower"] for i in vegetable: print(i) - correct answer ✔✔tree flower Iteration addresses the values in the list sequentially The value at that point in the sequence - correct answer ✔✔Indexing animal = ["mammal", "reptile", "fish", "bird", "insect"]
elif else: What is if-else? - correct answer ✔✔if statement can be used together with else What is if-elif? - correct answer ✔✔- if statement can be used together with one or more elif statements to set multiple tests.
Define for loop and its structure: - correct answer ✔✔Execute a code block for a specified number of times. Structure: for in : The is used as a counter that controls how many times the code block is executed. The is a sequence of values such as a list or a string. The takes each successive value of the . What is another type of