Python Objective 1

Question: Which statements will result in a slice of a tuple?

a_tuple[0] = [5]

a_tuple[::-1]

a_tuple[:]

a_tuple[::2]

Ans:-

a_tuple[::-1]

a_tuple[:]

a_tuple[::2]

Question: Which of these are valid commands that you can use with pip?

install

hold

freeze

uninstall

find

list

Ans:-

install

freeze

uninstall

list

Question: Which of these is a valid hash bang that will help the program loader determine which interpreter to use?

#&/usr/bin/env python3

#!/usr/bin/env python3

#$/usr/bin/env python3

##/usr/bin/env python3

Ans:- #!/usr/bin/env python3

Question: Which methods can be used with list objects?

Decode

Clear

Pop

Reverse

Lambda

Ans:-

Clear

Pop

Reverse

Question: Which statement will open a file so that you can write to it without overwriting the file entirely?

message_file = open(my_file, ‘w’)

message_file = open(my_file, ‘e’)

message_file = open(my_file, ‘a’)

message_file = open(my_file, ‘r’)

Ans:- message_file = open(my_file, ‘a’)

Question: Which statement successfully creates a zipfile using the zipfile module in Python?

backup_zip_file = zipfile.ZipFile(zip_filename, ‘w’)

backup_zip_file = zipfile.create(zip_filename, ‘w’)

backup_zip_file = zipfile.open(zip_filename, ‘w’)

backup_zip_file = ZipFile(zip_filename, ‘w’, “zipfile”)

Ans:- backup_zip_file = zipfile.ZipFile(zip_filename, ‘w’)

Question: If you do not choose the option to add python.exe to the path during the Windows installation process, what will need to be altered so that you can run Python code from any directory on the computer?

The ipconfig file

Environment variables

The init.exe file

Windows configuration

Ans:- Environment variables

Question: Which methods can be used with the tuple object?

Max

Append

Len

Sorted

Reverse

Ans:-

Max

Len

Sorted

Question: Which of these statements defines a tuple named ‘t’?

t.append(‘1, 2, 3’)

t = (1, 2, 3)

t = [1, 2, 3]

t = {1, 2, 3}

Ans:- t = (1, 2, 3)

V

Question: Which of the following commands are valid to store a numeric value of 2 in a variable named num_x?

num_x == 2

num_x = 2

num_x = 6 – 4

num_x = “2”

Ans:-

num_x = 2

num_x = 6 – 4

Question: Which of the following will not result in declaring x a data type of float?

x = int(y)

x = float(10)

x = float.fromhex(‘A’)

x = 5.

Ans:- x = int(y)

Question: How can you execute shell commands on Jupyter notebook code cells?

Prefix the shell command using @ i.e. @python –version

Enclose the command in quotes i.e. “python –version”

Prefix the shell command using ! i.e. !python –version

Just run the shell command like a Python command i.e. python –version

Ans:- Prefix the shell command using ! i.e. !python –version

Question: Which of the following functions are valid built-in functions in Python?

type()

clamp()

len()

print()

Ans:-

type()

len()

print()

Question: Which of the following is an open source distribution of the Python and R programming languages that uses the Conda package manager?

Jupyter

Cobra

Serpent

Anaconda

Ans:- Anaconda

Question: How can you execute shell commands on Jupyter notebook code cells?

Prefix the shell command using @ i.e. @python –version

Enclose the command in quotes i.e. “python –version”

Prefix the shell command using ! i.e. !python –version

Just run the shell command like a Python command i.e. python –version

Ans:- Prefix the shell command using ! i.e. !python –version

Question: Which of the following functions are valid built-in functions in Python?

type()

clamp()

len()

print()

Ans:-

type()

len()

print()

Question: Which of the following is an open source distribution of the Python and R programming languages that uses the Conda package manager?

Jupyter

Cobra

Serpent

Anaconda

Ans:- Anaconda

Question: Which statements describe bytearrays?

Bytearrays are immutable objects

A bytearray object can be created based upon a bytes object

The decode command has a default of UTF-16

Bytearrays contain a sequence of integers in the range 0 – 255

Without an argument, an array of size 0 is created

Ans:-

A bytearray object can be created based upon a bytes object

Bytearrays contain a sequence of integers in the range 0 – 255

Without an argument, an array of size 0 is created

Question: What data type is now represented by int in Python 3?

Short

Decimal

Long

Float

Ans:- Long

Question: Consider this bit of Python code:
Code Editor:
num_1 = 10
num_2 = 20
num_3 = num_1
num_1 = 100
What is the final value stored in num_3?

Indeterminate

10

100

20

Ans:- 10

Question: If you want to increment the value stored in the num_1 variable by 10 which of the following Python statements are valid?

num_1 = 10

num_1 == num_1 + 10

num_1 += 10

num_1 = num_1 + 10

Ans:-

num_1 += 10

num_1 = num_1 + 10

Question: Which statements accurately describe the bool class?

Boolean Or returns the first False or the last True value

Zero values are considered True

The bool class is a subclass of the array class

Boolean Not returns False if the operand is True

Ans:- Boolean Not returns False if the operand is True

Question: Which statement will correctly assign x as an infinite number?

x = pos_infinity

x = float(‘inf’)

x = int(‘inf’)

x = infinity

Ans:- x = float(‘inf’)

Question: What is the correct syntax for specifying multi-line strings in Python?

‘This is a multi-line string ‘

“ This is a multi-line string ”

“”” This is a multi-line string “””

“” This is a multi-line string ””

Ans:- “”” This is a multi-line string “””

Question: Which of the following are valid string operations in Python?

“Hello” / “World”

“Hello” * “World”

“Hello” + “World”

“Hello” * 3

Ans:-

“Hello” + “World”

“Hello” * 3

Question: Which key combination will exit the Python shell when accessed through the terminal in a Linux environment?

Ctrl+D

Ctrl+F6

Alt+F12

Alt+X

Ans:-

Ans:- Ctrl+D

Question: As a new user of Python which version of Python should you use?

Beginners should only use Python 2.7

Beginners should only use Python 3.7

Either version of Python is fine but 3.7 should be preferred

Either version of Python is fine but 2.7 should be preferred

Ans:- Either version of Python is fine but 3.7 should be preferred

Question: Which of the following terms best describes Jupyter notebooks that you can use to write Python code?

Interactive

Meant only for advanced Python users

Can view results on the same screen as the code

Browser-based

Ans:-

Interactive

Can view results on the same screen as the code

Browser-based

Question: Which statements will result in a slice of a tuple?

a_tuple[0] = [5]

a_tuple[::-1]

a_tuple[:]

a_tuple[::2]

Ans:-

a_tuple[::-1]

a_tuple[:]

a_tuple[::2]

Question: Consider two Python variables initialized as shown below. Which of the following logical statements below will have a value of True?
Code Editor:
a = True
b = True

not b

not a

a and b

a or b

Ans:-

a and b

a or b

Question: Which of the following are valid data types in Python?

character

bool

float

number

int

Ans:-

bool

float

int

Question: Which of the following methods can be used with the dict class?

Keys

Lambda

Values

Copy

Ans:-

Keys

Values

Copy

Question: If you wanted to sort the elements in the list names_list in alphabetical order which of the following statements in Python are valid?

names_list.alphabetical_sort()

names_list = sorted(names_list)

names_list.sort()

names_list = sort_alpha(names_list)

Ans:-

names_list = sorted(names_list)

names_list.sort()

Question: Which of the following lines of code will print this string in reverse i.e. print out “olleH”

Code Editor:
some_str = “Hello”

some_str[::-1]

some_str[1::2]

reverse(some_str)

some_str[-1: 0: -1]

Ans:- some_str[::-1]

Question: Which of the following can be used to exit a while loop before the condition has been evaluated as false?

Exit

Endpoint

Stop

Break

Ans:- Break

Question: If you want to count the number of times the name “John” appears in the names_list what function would you invoke?

names_list.count_all(“john”)

names_list.times(“John”)

names_list.count(“John”)

names_list.count_all(“john”)

Ans:- names_list.count(“John”)

Question: What will be the result of this slicing operation of the names_list?

Code Editor:
names_list = [‘John’, ‘James’, ‘Lily’, ‘Emily’, ‘Nina’]
names_list[::2]

[ ‘James’, ‘Emily’]

[ ‘Lily’, ‘Emily’, ‘Nina’]

[‘John’, ‘Lily’, ‘Nina’]

[‘John’, ‘Nina’]

Ans:- [‘John’, ‘Lily’, ‘Nina’]

Question: When using the Python shell and a code block, what triggers the interpreter to begin evaluating the block of code?

A blank line

The semi-colon symbol

The execute command

The closed parenthesis

Ans:- A blank line

Question: Which of the following can be used to end the current iteration and perform the evaluation again in a for loop?

Endpoint

Continue

Break

Exit

ANs:- Continue

Question: What is the result of executing this code?

Code Editor:
some_string = “Python”
a, b, c, d = some_string

This is an error, “too many values to unpack”

This is invalid syntax

All variables a, b, c and d will hold the string “Python”

The variable a will hold ‘P’, b will hold ‘y’, c will hold ‘t’ and so on

Ans:- This is an error, “too many values to unpack”

Question: What is the result of executing this code?

Code Editor:
city = ‘Los Angeles’
city.find(‘x’)

-1

2

Substring not found error

9

Ans: -1

Why will the given code example not print anything?

length = 0
if length:
print(“Hello World!”)

The object was not properly instantiated

Variables can only be identified as strings

There is not an endif statement

The condition is false

Ans:- The condition is false

Question: Consider the list:

Code Editor:
some_list = [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’]

How do you slice this list to access the elements ‘c’, ‘d’?

some_list[2:3]

some_list[0:2]

some_list[2]

some_list[2:4]

Ans:- some_list[2:4]

Question: If you wanted to insert an element at index 2 in a particular list named names_list what is the function that you would invoke?

names_list.append(“John”)

names_list.insert(2, “John”)

names_list.add(2“John”)

names_list.append(2, “John”)

Ans:- names_list.insert(2, “John”)

Question: Which methods can be used with list objects?

Decode

Clear

Pop

Reverse

Lambda

Ans:-

Clear

Pop

Reverse

Question: All of the following statements are ways in which lists and tuples are different. Which one of these is true?

A list is an ordered collection, a tuple is an unordered collection

List elements start at 0, tuple elements start at 1

A list can contain elements of different data types, in a tuple all elements should be of the same data type

A list can be changed once creating, a tuple is immutable and cannot be changed

Ans:- A list can be changed once creating, a tuple is immutable and cannot be changed

Question: Which of the following statements about Python lists are true?

Lists in Python can have elements of different data types

Lists are ordered collections

Lists, once created cannot be changed

You can add elements to a list but you cannot delete elements from a list

Ans:-

Lists in Python can have elements of different data types

Lists are ordered collections

Question: All of the following statements are ways in which lists and tuples are different. Which one of these is true?

A list is an ordered collection, a tuple is an unordered collection

List elements start at 0, tuple elements start at 1

A list can contain elements of different data types, in a tuple all elements should be of the same data type

A list can be changed once creating, a tuple is immutable and cannot be changed

Ans:- A list can be changed once creating, a tuple is immutable and cannot be changed

Question: Which of the following statements about Python lists are true?

Lists in Python can have elements of different data types

Lists are ordered collections

Lists, once created cannot be changed

You can add elements to a list but you cannot delete elements from a list

Ans:-

Lists in Python can have elements of different data types

Lists are ordered collections

Identify the methods that can be used with sets.

append

pop

issuperset

symmetric_difference

isdisjoint

Ans:-

pop

issuperset

symmetric_difference

isdisjoint

Question: All of the following statements are ways in which lists and tuples are similar. Which one of these is NOT true?

Both, once created, cannot be updated

Both can contain elements of different data types

Both represent an ordered collection of elements

Elements in both can be accessed starting at index 0

Ans:- Both, once created, cannot be updated

Question: Which of the following are valid complex data types in Python?

Sets

Dictionaries

Lists

Collections

Ans:-

Sets

Dictionaries

Lists

Which of the following will create a range?

range(5)

range(10, -1, -1)

range(20, 25)

range(, , -2)

Ans:-

range(5)

range(10, -1, -1)

range(20, 25)

How would you update the names_ages dictionary with the values in updated_names_ages dictionary?

names_ages = updated_names_ages

names_ages.insert(updated_names_ages)

names_ages.updatekeys(updated_names_ages)

names_ages.update(updated_names_ages)

Ans:- names_ages.update(updated_names_ages)

Question: Consider a nested list of names and ages:

Code Editor:
names_ages = [[‘John’, 35], [‘Jill’, 38], [‘Tim’, 27]]

How would you convert this to a dictionary with names as the keys and ages as values?

convert_to_dict(names_ages)

dict(names_ages)

The converstion cannot be done

to_dict(names_ages)

Ans:- dict(names_ages)

Question: Consider two sets of integers:

Code Editor:

set_1 = {2, 4, 6, 8}
set_2 = {1, 2, 5, 6, 7, 8}

What operation would I run to get a result set with all of the elements from both sets?

set_1.union(set_2)

set_1.intersection(set_2)

set_1.difference(set_2)

set_1.add(set_2)

Ans:- set_1.union(set_2)\

Question: Which methods can be used with the tuple object?

Max

Append

Len

Sorted

Reverse

Ans:-

Max

Len

Sorted

Question: Consider a dictionary of names and ages set up as below:

Code Editor:
names_ages = {‘John’: 35, ‘Jim’: 45, ‘Alice’: 25}

How would you look up Alice’s age in this dictionary?

names_ages”Alice”

names_ages[‘Alice’]

names_ages(‘Alice’)

names_ages{Alice}

Ans:- names_ages[‘Alice’]

Question: A set in Python can contain which of the following data types?

Tuples

Floats

Lists

Dictionaries

Strings

Ans:-

Tuples

Floats

Strings

Question: Consider a dictionary of names and ages set up as below:

Code Editor:
names_ages = {‘John’: 35, ‘Jim’: 45, ‘Alice’: 25}

What would the output be if you were to run this code?

names_ages[‘Tim’]

“”

0

None

KeyError: ‘Tim’

Ans:- KeyError: ‘Tim’

Question: What are possible solutions when you have trouble importing a module you created?

Change the working directory to be the one that contains the module

Add the path for the module to the sys.path file

Change the location of the importlib module

Add the module name to the py.py file

Ans:-

Change the working directory to be the one that contains the module

Add the path for the module to the sys.path file

Question: Consider a nested list of names and ages:

Code Editor:
names_ages = [[‘John’, 35], [‘Jill’, 38], [‘Tim’, 27]]

How would you access Tim’s age in this nested list?

names_ages[2]{1}

names_ages[2, 1]

names_ages[2][1]

names_ages{2}{1}

Ans:- names_ages[2][1]

Question: What does using the if name == ‘main’: syntax allow programmers to do?

Change the default namespace

Allow the module to be imported

Execute the that code block directly from the command line

Test the module to make sure that it is working properly

Ans:-

Execute the that code block directly from the command line

Test the module to make sure that it is working properly

Question: Which characteristics describe the Python programing language?

It is an open source language

It is a compiled language

It is an assembly language

It is an interpreted language
Ans:-

It is an open source language

It is an interpreted language

Question: What are some characteristics of a properly defined function?

The return keyword causes an exit from the function with the value

It must always accept at least one parameter

It must always return a value

It can be defined to accept an unlimited amount of arguments

Ans:-

The return keyword causes an exit from the function with the value

It can be defined to accept an unlimited amount of arguments

Question: What is the default namespace a program will run in?

The system namespace

The python namespace

The main namespace

The scripting namespace

Ans:- The main namespace

Question: Which of the following will not result in declaring x a data type of float?

x = int(y)

x = float(10)

x = float.fromhex(‘A’)

x = 5.

Ans:- x = int(y)

Question: What must you use to allow for command line arguments to be passed to a function in a module or script?

python.terminal

py.py

win.command

sys.argv

Ans:- sys.argv

Question: Which statements describe bytearrays?

Bytearrays are immutable objects

A bytearray object can be created based upon a bytes object

The decode command has a default of UTF-16

Bytearrays contain a sequence of integers in the range 0 – 255

Without an argument, an array of size 0 is created

Ans:-

A bytearray object can be created based upon a bytes object

Bytearrays contain a sequence of integers in the range 0 – 255

Without an argument, an array of size 0 is created

Question: What are some characteristics of the relationship between classes and types?

A class can be defined as a specific type

An instance of a class will have the string that was used to define the class as its type

A type can be defined as a specific class

A type will have the main class in its definition

Ans:-

A class can be defined as a specific type

An instance of a class will have the string that was used to define the class as its type

Question: If something is declared as a property, what then must be used to modify the value?

The @property notation

A getter function

The property._property command

A setter function

Ans:- A setter function

Question: What is code that follows the Python philosophy referred to as?

Pythological

Tre Python

Pythonic

Monty Python

Ans:- Pythonic

Question: What special method must be used to create objects with instances customized to a specific initial state?

_ _self_ _

_ _str_ _

_ _init_ _

_ _main_ _

Ans:- _ _init_ _

Question: What is the decorator used to denote a class method, as opposed to an instance method?

main_namespace

_ _ init _ _

(self)

@classmethod

Ans:- @classmethod

Question: Which statements accurately describe the bool class?

Boolean Or returns the first False or the last True value

Zero values are considered True

The bool class is a subclass of the array class

Boolean Not returns False if the operand is True

Ans:- Boolean Not returns False if the operand is True

Question: What is the decorator used to declare a static method?

@static

@staticmethod

@method

@classmethod

Ans:- @staticmethod

Question: Which statement correctly creates a class using inheritance?

class DerivedClass():

class DerivedClass -> BaseClass:

class DerivedClass (BaseClass1, BaseClass2):

DerivedClass (BaseClass)

Ans:- class DerivedClass (BaseClass1, BaseClass2):

Question: Which statement will correctly assign x as an infinite number?

x = pos_infinity

x = float(‘inf’)

x = int(‘inf’)

x = infinity

Ans:- x = float(‘inf’)

Question: What benefits does overloading an operator provide to a programmer?

Change the class type in the middle of the usage

Include additional automatic functionality to occur when operations are done

Perform garbage collection

Have the object appear in a particular way when printed or inspected by the interpreter

Ans:-

Include additional automatic functionality to occur when operations are done

Have the object appear in a particular way when printed or inspected by the interpreter

Question: Which of the following does a class in Python allow you to represent?

A method

An object

A path

A variable

Ans:- An object

Question: What are the main current versions of Python?

1.x and 7.x

43 and 56

XP and 8

2.x and 3.x

Ans:- 2.x and 3.x

Question: When attempting to overwrite a setter from an inherited class, what must also be declared in the subclass?

The instance

The overwriter

The submask

The property

Ans:- The property

Question: Which of the following methods can be used with the dict class?

Keys

Lambda

Values

Copy

Ans:-

Keys

Values

Copy

Question: The docstring is useful for documentation but will also be returned with which method?

The str method

The init method

The repr method

The help method

Ans:- The help method

Question: What is the downside to reading entire files before writing them, rather than using one line at a time methods of iteration or the readline method?

There is a large chance for data loss

Memory consumption can be exceeded on very large files

Iteration techniques are too slow

Python doesn’t have the ability to read entire files

Ans:- Memory consumption can be exceeded on very large files

Question: Which of the following can be used to exit a while loop before the condition has been evaluated as false?

Exit

Endpoint

Stop

Break

Ans:- Break

Question: Which of the following are valid modes to set when writing to a file?

x

a

s

r

Ans:x,a

Question: What letter needs to be added to the mode when you are reading a binary file?

b

q

s

p

Ans:- b

Question: By default, how many spaces are code suites indented when using the Python IDLE?

3

4

5

2

Ans:- 4

Question: Which are the techniques for reading a text file?

Iterating over lines

Using the readlines method

Using the read method

Using the scan method

Ans:-

Iterating over lines

Using the readlines method

Using the read method

Question: In order to be able to write binary data to a file, you need to use either the struct module pack. Which other object can you use to encode data, like text, into binary data?

The encode object

The bind object

The bytes object

The convert object

Ans:- The bytes object

Question: Which of the following can be used to end the current iteration and perform the evaluation again in a for loop?

Endpoint

Continue

Break

Exit

ANs:- Continue

Question: Which line of code will correctly unpack a zipped file of keys and values?

zip_a, zip_b = zip(*zip(keys, values))

zip_a : [zip(keys, values)]

zip_a = zip(zip_b(keys, values))

zip_a == zip(keys, values)

Ans:- zip_a, zip_b = zip(*zip(keys, values))

Question: Which of the following characteristics are reasons to use a list comprehension?

They use longer code blocks

They make the code more readable

They make the code more concise

They use loops to create lists

Why will the given code example not print anything?

length = 0
if length:
print(“Hello World!”)

The object was not properly instantiated

Variables can only be identified as strings

There is not an endif statement

The condition is false

Ans:- The condition is false

Question: Which of the following options will create a nested list comprehension?

matrix_a == ( [3, 4, 5] [3, 4, 5] )

matrix_a != ( [4, 5, 6] [3, 2, 1] )

matrix_a = [ [0, 0, 0], [0, 0, 0] ]

matrix_a : ( [2, 3, 5] [12, 24 15] )

Ans:- matrix_a = [ [0, 0, 0], [0, 0, 0] ]

Question: What are the major differences of a set comprehension versus a list comprehension?

They generate without the use of loops

The values they produce must be immutable

They are less readable than lists

They generate sets instead of lists

Ans:-

The values they produce must be immutable

They generate sets instead of lists

Question: In what format does the input function read in user input?

Array

Boolean

Object

String

Ans:- String

Question: You want to avoid having too few variable declarations for the amount of items in the sequence.
What special character can be added to a variable declaration over an iterable with an undetermined length?

#

@

*

^

Ans:- *

Identify the methods that can be used with sets.

append

pop

issuperset

symmetric_difference

isdisjoint

Ans:-

pop

issuperset

symmetric_difference

isdisjoint

Question: Which of the following methods can be used on an object that is an iterator, to iterate through a sequence?

__ init __

__ iter __

__ hasattr_ _

_ _next __

Ans:- __next__

Question: What is the alternative if the iter method is not defined in a custom class to make it iterable?

__init__

__dir__

__name__

__getitem__

Ans:- __getitem__

Which of the following will create a range?

range(5)

range(10, -1, -1)

range(20, 25)

range(, , -2)

Ans:-

range(5)

range(10, -1, -1)

range(20, 25)

Question: Which line of code correctly uses the reduce function?

orbs = reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])

orbs : reduce(1, 2, 3, 4, 5)

orbs == list(reduce(x+y)

orbs = (1, 2, 3, 4, 5).reduce, x+y

Ans:- orbs = reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])

Question: What makes a generator recursive?

It continues to execute itself until the evaluation becomes false

It fails to use the yield return type

It does not use a loop to perform iterations

It can be replaced by a list comprehension

Ans:- It continues to execute itself until the evaluation becomes false

Question: Which action should be avoided so that you do not mistakenly overwrite names that you have already defined?

Import selectively with aliases

Use aliases when importing

Use the wildcard import

Import selective objects

Ans:- Use the wildcard import

Question: When using the map function, how many iterables can be passed?

Unlimited

Zero

One

The amount the function requires

Ans:- The amount the function requires

Question: Which keyword, used instead of return, identifies a function being defined, as a generator?

yield

give

examine

getitem

Ans:- yield

Question: What command is used to output text from both the Python shell and within a Python module?

print()

OutputStream()

count()

System.out.println()

Ans:- print()

Question: What command is used to output text from both the Python shell and within a Python module?

print()

OutputStream()

count()

System.out.println()

Ans:- print()

Question: What are some of the characteristics that make up a lazy generator?

You do not need to wait for all elements to be generated to start using them

They take up more memory

Once they are used they become empty

They are generated on demand

Ans:-

You do not need to wait for all elements to be generated to start using them

Once they are used they become empty

They are generated on demand

Question: What are the two functions that must be defined in a custom class to make it iterable?

__iter__

__next__

__main__

__hadattr__

Ans:-

__iter__

__next__

Question: What data type is now represented by int in Python 3?

Short

Decimal

Long

Float

Ans:- Long

Question: What can be used in the except block to catch all exceptions?

Raise

Try

Catch

BaseException

Ans:- BaseException

Question: Why is understanding exception hierarchy important?

So that the programmer can decide to what degree he/she wants to handle different types of exceptions

So that the programmer can code exceptions knowing that there will always be a built in exception handler for the errors he/she does not account for

So that feedback is always presented to the end user in the same generic way

So that the code can be compiled to its least specific exception knowing that the interpreter will handle the specificity

Ans:-So that the programmer can decide to what degree he/she wants to handle different types of exceptions

Question: Which statements prevent the escape sequence interpretation?

col1\tcol2\tcol3\t

subtext’col1\tcol2\tcol3\t’

r’col1\tcol2\tcol3\t’

escape’col1\tcol2\tcol3\t’

Ans:- r’col1\tcol2\tcol3\t’

Question: Complete the code to calculate a number’s exponent value.

Code Editor:
def exp(x,y):
val = 1
for i in range(y):
val
return val

/= val

*= x

*= val

/= x

Ans:- *= x

Question: Which of these are comparison operators?

=

&

!=

==

Ans:-

!=

==

Question: What command can be used to install most packages from the Python Package Index (PyPI)?

pip

pypi

pypinstall

pyp

Ans:- pip

Question: Which statement creates a bytes literal when run?

bytes_literal = bytes.str.count(0x54)

bytes_literal = bytes(str_literal, ‘utf-8’)

bytes_literal = b’Copyright \xc2\xa9′

bytes_literal = bytes_encoded.count(0x54)

Ans:- bytes_literal = b’Copyright \xc2\xa9′