• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 18 pages
Exam (elaborations)

Python Datacamp Interm 3 100% Verified

Document preview thumbnail
Preview 3 out of 18 pages

Python Datacamp Interm 3 100% Verified...

Content preview

Python Datacamp Interm 3 100% Verified


error = 1



while error < 4:

print(error)

error = error + 1



what is the output? - ANSWER 1

2

3



fam = [1.73, 1.68, 1.71, 1.89]



print each of element seperately - ANSWER for height in fam :

print(height)



fam = [1.73, 1.68, 1.71, 1.89]

???

index 0: 1.73

index 1: 1.68

index 2: 1.71

index 3: 1.89 - ANSWER for index, height in enumerate(fam) :

print("index " + str(index) + ": " + str(height))

,house = [["hallway", 11.25],

["kitchen", 18.0],

["living room", 20.0],

["bedroom", 10.75],

["bathroom", 9.50]]




???



the hallway is 11.25 sqm

the kitchen is 18.0 sqm

the living room is 20.0 sqm

the bedroom is 10.75 sqm

the bathroom is 9.5 sqm - ANSWER for x in house:

print('the ' + x[0] + ' is ' + str(x[1]) +' sqm')



Loop over dictionary



world = { "afghanistan":30.55, "albania":2.77, "algeria":39.21 }



what order would the output take? - ANSWER items() method



for key, value in world.items() : print(key + " -- " + str(value))



algeria -- 39.21

afghanistan -- 30.55

albania -- 2.77

, the order in which they iterate is not fixed

dictionaries are inherently unordered



europe = {'spain':'madrid', 'france':'paris', 'germany':'berlin',

'norway':'oslo', 'italy':'rome', 'poland':'warsaw', 'austria':'vienna' }



???



the capital of norway is oslo

the capital of austria is vienna

the capital of spain is madrid

the capital of france is paris

the capital of italy is rome

the capital of poland is warsaw

the capital of germany is berlin - ANSWER for x, y in europe.items():

print ('the capital of ' + x + ' is ' + y)



loop for Numpy array



my_array([[ 74, 180],

[ 74, 215],

[ 72, 210], - ANSWER for 1D array

for x in my_array:



for 2D array:

function

Document information

Uploaded on
January 19, 2025
Number of pages
18
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$12.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Easton
3.9
(124)
Sold
608
Followers
221
Items
28047
Last sold
4 days ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions