0
0
Data Analysis Pythondata~20 mins

Google Colab as alternative in Data Analysis Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Google Colab Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of code using Google Colab environment variables
What will be the output of this code snippet when run in Google Colab?
Data Analysis Python
import os
print(os.environ.get('COLAB_GPU'))
A'0'
BNone
C'1'
DRaises KeyError
Attempts:
2 left
💡 Hint
Google Colab sets some environment variables only when GPU is enabled.
data_output
intermediate
2:00remaining
DataFrame output after reading CSV in Google Colab
Assuming you upload a CSV file named 'data.csv' with columns 'A' and 'B' and values [[1,2],[3,4]], what will be the output of this code in Google Colab?
Data Analysis Python
import pandas as pd
df = pd.read_csv('data.csv')
print(df)
A
   A  B
1  1  2
2  3  4
BError: FileNotFoundError
C
   A  B
0  1  2
1  3  4
D
Empty DataFrame
Columns: [A, B]
Index: []
Attempts:
2 left
💡 Hint
In Google Colab, uploaded files are accessible in the current working directory.
visualization
advanced
2:00remaining
Plot display behavior in Google Colab
Which option correctly describes what happens when you run this code in Google Colab?
Data Analysis Python
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.show()
AThe code raises a RuntimeError about display backend.
BThe plot opens in a new window outside the browser.
CNo plot is displayed unless you save it to a file first.
DThe plot is displayed inline below the code cell.
Attempts:
2 left
💡 Hint
Google Colab supports inline plotting by default.
🔧 Debug
advanced
2:00remaining
Fixing file path error in Google Colab
You run this code in Google Colab but get a FileNotFoundError. What is the most likely cause?
Data Analysis Python
with open('/content/myfile.txt', 'r') as f:
    data = f.read()
print(data)
AThe file 'myfile.txt' is not uploaded or not in /content directory.
BThe file path should be relative like 'myfile.txt' without /content prefix.
CGoogle Colab does not allow reading files from /content directory.
DThe open function requires mode 'rb' for text files in Colab.
Attempts:
2 left
💡 Hint
Check if the file exists in the specified path in Colab.
🚀 Application
expert
3:00remaining
Using Google Colab to run a machine learning model
You want to train a machine learning model on a large dataset using Google Colab. Which of these steps is NOT necessary or recommended?
ASave the trained model only locally on your computer without uploading or downloading.
BUse GPU acceleration by enabling it in Colab settings if available.
CUpload the dataset to Google Drive and mount it in Colab for access.
DInstall required Python packages in each new Colab session before running code.
Attempts:
2 left
💡 Hint
Consider how Colab sessions work and where files persist.