0
0
GCPcloud~10 mins

Why Cloud Storage matters for object data in GCP - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new Cloud Storage bucket named 'my-bucket'.

GCP
from google.cloud import storage
client = storage.Client()
bucket = client.create_bucket('[1]')
Drag options to blanks, or click blank then click option'
A'data-bucket'
B'bucket123'
C'storage-bucket'
D'my-bucket'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the bucket name
Using an incorrect bucket name
2fill in blank
medium

Complete the code to upload a file 'photo.jpg' to the bucket.

GCP
bucket = client.get_bucket('my-bucket')
blob = bucket.blob('[1]')
blob.upload_from_filename('photo.jpg')
Drag options to blanks, or click blank then click option'
A'photo.jpg'
B'image.png'
C'document.txt'
D'video.mp4'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different file name than the one uploaded
Missing quotes around the blob name
3fill in blank
hard

Fix the error in the code to download 'photo.jpg' from the bucket to local file 'downloaded.jpg'.

GCP
bucket = client.get_bucket('my-bucket')
blob = bucket.blob('photo.jpg')
blob.[1]('downloaded.jpg')
Drag options to blanks, or click blank then click option'
Aupload_from_filename
Bdownload_to_filename
Cdownload_from_filename
Dupload_to_filename
Attempts:
3 left
💡 Hint
Common Mistakes
Using upload methods instead of download
Mixing method names
4fill in blank
hard

Fill both blanks to list all blobs in 'my-bucket' and print their names.

GCP
bucket = client.get_bucket('my-bucket')
blobs = bucket.[1]()
for blob in blobs:
    print(blob.[2])
Drag options to blanks, or click blank then click option'
Alist_blobs
Bname
Cblob_name
Dget_blobs
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names
Using wrong attribute for blob name
5fill in blank
hard

Fill all three blanks to delete a blob named 'old_file.txt' from 'my-bucket'.

GCP
bucket = client.get_bucket('[1]')
blob = bucket.blob('[2]')
blob.[3]()
Drag options to blanks, or click blank then click option'
Amy-bucket
Bold_file.txt
Cdelete
Dremove
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong method name like 'remove'
Mixing bucket or blob names