Docsity

Python Basics Quiz: Test Your Knowledge, Exams of Computer Science

Partial preview of the text

Download Python Basics Quiz: Test Your Knowledge and more Exams Computer Science in PDF only on Docsity!

Quiz 1 - Python Basics: Python - Foundations - Great Learning

Quiz 1 - Python Basics

Type : Practice Quiz Attempts : 1/ Questions : 10 Time : 10m Due Date : Jan 25 , 1:29 PM Your Marks : 8/ Instructions

Attempt History

Attempt # Jan 22, 5:25 PM Marks: 8 Q No: 1 Correct Answer The purpose of a variable is Marks: 1/

a value that cannot be altered by the program during normal execution, i.e., the value is constant its usefulness for defining values that are used many times within a function or program None of the above The purpose of a variable is to store information (numbers, strings, data structures) to be referenced or manipulated in a program. constants None of the above a, b, and c store data in them (5, 10, 5+10), and hence, they are variables. Q No: 2 a=5, b=10, c=a+b= Here a, b, and c are referred to as Marks: 1/ Q No: 3 Which of the following is the data type (int/str/float) of 1289.0? Marks: 1/ to label and store data in memory (^) You Selected variables (^) You Selected Correct Answer Correct Answer

True (^) You Selected False Dictionary is a data structure that stores data in the form of key-value pairs - {key: value}. Eg: {“Audi”: 1900, “BMW”: 1850} True False (^) You Selected A numpy array can be created from another data structure (like a list) by using np.array(). Hence, the correct way to define an array will be In Python, a dictionary consists of key-value pairs. Q No: 6 Tuples are mutable. Marks: 1/ Q No: 7 An example of an array can be Marks: 1/ True False (^) You Selected Once a tuple is defined, it’s not possible to add, remove or modify elements in it. arr = np.arr([[1],[3],[5]]) Correct Answer Correct Answer

True (^) You Selected False A dictionary stores data as key-value pairs, where the keys and the values are separated by a colon (:). True (^) You Selected False (^) Correct Option We can get the dimensions of a matrix using shape (matrix.shape). In this case, we will get (3,2) as output, which shows that it has 3 rows and 2 columns. Q No: 8 The following syntax to define a dictionary is correct. Marks: 1/ Q No: 9 The matrix defined by the code below has 3 rows and 4 columns. Marks: 0/ Q No: 10 arr= np.array([[1],[3],[5]]) dictionary = {"MARKS": 75, "RANK": 7} matrix = np.array([[1,2],[3,4],[5,6]]) Correct Answer Incorrect Answer Correct Answer