100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Python Test Questions with Answers R244,70   Add to cart

Exam (elaborations)

Python Test Questions with Answers

 15 views  0 purchase
  • Course
  • Python
  • Institution
  • Python

Python Test Questions with Answers What do the following lines of code do? with open("E","w") as writefile: ("This is line An") ("This is line Bn") Read the file "E" Write to the file "E" Append the file "E" - Answer-Write to the file "E" What do the following lines of code do? wit...

[Show more]

Preview 2 out of 7  pages

  • August 12, 2024
  • 7
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • Python
  • Python
avatar-seller
Python Test Questions
with Answers
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")

Read the file "Example2.txt"
Write to the file "Example2.txt"
Append the file "Example2.txt" - Answer-Write to the file "Example2.txt"

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

Read the file "Example3.txt"
Write to the file "Example3.txt"
Append the file "Example3.txt" - Answer-Append the file "Example3.txt"

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

prints the first row of the dataframe
prints the first column of the dataframe
prints the first 5 rows of the dataframe
prints the dateframe out - Answer-prints the first 5 rows of the dataframe

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

0
array([1, 1, 1, 1, 1])
array([0, 0, 0, 0, 0]) - Answer-array([0, 0, 0, 0, 0])

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

, 1
array([1,1])
0
array([0,0]) - Answer-0

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

array([10,10,10,10,10])
array([11, 11, 11, 11, 11])
array([1,1,1,1,1]) - Answer-array([11, 11, 11, 11, 11])

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

np.dot(A,B)
A*B
AxB - Answer-np.dot(A,B)

What is the type of the following variable: a=True? - Answer-Bool

What is the result of the following operation int(3.2)? - Answer-3

Consider the string A='1234567', what is the result of the following operation: A[1::2] -
Answer-'246'

Consider the string Name="Michael Jackson" , what is the result of the following
operation Name.find('el') - Answer-5

The variables A='1' and B='2' ,what is the result of the operation A+B? - Answer-'12'

What is the result of the following operation in Python:

3+2*2

10
7
9
12 - Answer-7

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

Lizz
L
Liz

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying this summary from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Perfectscorer. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy this summary for R244,70. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79223 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy summaries for 14 years now

Start selling
R244,70
  • (0)
  Buy now