Python

¡Supera tus tareas y exámenes ahora con Quizwiz!

What do the following lines of code do? with open("Example3.txt","a") as file1: file1.write("This is line C\n")

Append the file "Example3.txt"

What do the following lines of code do? with open("Example1.txt","r") as file1: FileContent=file1.readlines() print(FileContent)

Read the file "Example1.txt" Read the file "Example1.txt"

Consider the function Delta, when will the function return a value of 1 def Delta(x): if x==0: y=1; else: y=0; return(y)

When the input is 0 When the input is 0 - correct

After applying the following method,L.append(['a','b']), the following list will only be one element longer.

True

In Python, if you executed var = '01234567', what would be the result of print(var[::2])?

0246

What is the output of the following few lines of code ? A=['1','2','3'] for a in A: print(2*a)

'11' '22' '33' '11' '22' '33'

In Python, what is the result of the following operation '1'+'2'

'12'

Consider the following Python Dictionary: Dict={"A":1,"B":"2","C":[3,3,3],"D":(4,4,4),'E':5,'F':6} , what is the result of the following operation: Dict["D"]

(4, 4, 4)

what is the result of the following lines of code: a=np.array([0,1]) b=np.array([1,0]) np.dot(a,b)

0

How many duplicate elements can you have in a set?

0, you can only have one unique element in a set

what is the result of the following lines of code: a=np.array([0,1,0,1,0]) b=np.array([1,0,1,0,1]) a*b

array([0, 0, 0, 0, 0]) array([0, 0, 0, 0, 0])

What is the output of the following lines of code: x=1 if(x!=1): print('Hello') else: print('Hi') print('Mike')

Hi Mike

In Python, if you executed name = 'Lizz', what would be the output of print(name[0:2])?

Li

What is an important difference between lists and tuples?

Lists are mutable tuples are not

What is the syntax to obtain the first element of the tuple: A=('a','b','c')

A[0]

What is the result of the following operation in Python: 3 + 2 * 2

7

What is the correct way to sort the list 'B' using a method, the result should not return a new list, just change the list 'B'.

B.sort()

Consider the function Delta, when will the function return a value of 1 def Delta(x): if x==0: y=1; else: y=0; return(y)

When the input is 0 When the input is 0

What do the following lines of code do? with open("Example2.txt","w") as writefile: writefile.write("This is line A\n") writefile.write("This is line B\n")

Write to the file "Example2.txt" Write to the file "Example2.txt"

what are the keys of the of the following {'a':1,'b':2}

a,b

what is the result of the following lines of code: a=np.array([1,1,1,1,1]) a+10

array([11, 11, 11, 11, 11]) array([11, 11, 11, 11, 11])

Given myvar = 'hello', how would you convert myvar into uppercase?

myvar.upper()

what is the correct code to perform matrix multiplication on the matrix A and B

np.dot(A,B) np.dot(A,B)

What is the result of applying the following method df.head(), to the dataframe df

prints the first 5 rows of the dataframe


Conjuntos de estudio relacionados

Combo with NOBCChE Science Bowl: EARTH SCIENCE Set 1 and 16 others

View Set

ABNORMAL PSYCH FINAL Study Guide

View Set

Business Planning A: The Business Planning Model

View Set