Python 1 Final Exam Questions and Answers
Python 1 Final Exam Questions and Answers The definition of a variable is ____. - Correct Answer️️ -a storage location in a computer program What is the value of the variable named num after the following code snippet? num = 5 num2 = 6 num = num2 + 3 - Correct Answer️️ -9 What is the right way to assign the value of num + 10 to the variable num2? - Correct Answer️️ -num2 = num + 10 What is wrong here? 2ndNum = 78 - Correct Answer️️ -The 2ndNum variable is not a valid variable name Which line of code creates a variable named x and initializes it to the integer 5? - Correct Answer️️ -x = 5 Which of the following statements correctly calculates the average of three numbers, num1, num2, and num3? - Correct Answer️️ -( num1 + num2 + num3 ) / 3 A(n) ______ is a collection of programming instructions that carry out a particular task. - Correct Answer️️ -function If x=5.64, what is returned by this function? round(x) - Correct Answer️️ -6PDF DOCUMENT What must be done first before you can use a function from the standard library? - Correct Answer️️ -the function must be imported What is wrong with the following code snippet? ((num1 + num2) * num3 / 2 * (1 - num4) - Correct Answer️️ -there is an extra parenthesis What is it called when you splice two strings together in Python? - Correct Answer️️ - concatenation Given the code snippet below, what code is needed to print the person's initials? firstName = "Pamela" middleName = "Rose" lastName = "Smith" - Correct Answer️️ -print(firstName[0], middleName[0], lastName[0]) Which statement finds the last letter of the string variable name? - Correct Answer️️ - last = name[len(name) - 1] What is the default data type of input from the keyboard? - Correct Answer️️ -string Given the following statement, what statement correctly saves the number of items in the variable named quantity as an integer? userInput = input("Please enter the quantity: ") - Correct Answer️️ -quantity = int(userInput) What is the output for the following code snippet? area = 25 print("The area is %05d" % area) - Correct Answer️️ -The area is 00025PDF DOCUMENT From a python point of view, what is wrong with this statement? 72 = trombones - Correct Answer️️ -the variable must be on the left of the equal sign If you divide 2 integers with the / operator you get ____. - Correct Answer️️ -a floating point number If you divide 2 integers with the // operator you get ____. - Correct An
Written for
- Institution
- Python Programming
- Course
- Python Programming
Document information
- Uploaded on
- June 17, 2024
- Number of pages
- 34
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
python 1 final exam questions and answers
Also available in package deal