0
0
Snowflakecloud~10 mins

Snowpark for Python basics in Snowflake - Interactive Code Practice

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

Complete the code to create a Snowpark session.

Snowflake
from snowflake.snowpark import Session

connection_parameters = {
    "account": "my_account",
    "user": "my_user",
    "password": "my_password",
    "role": "SYSADMIN",
    "warehouse": "COMPUTE_WH",
    "database": "MY_DB",
    "schema": "PUBLIC"
}

session = Session.[1](connection_parameters)
Drag options to blanks, or click blank then click option'
Aconnect
Bcreate
Cstart
Dopen
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'create' instead of 'connect' causes an AttributeError.
Using 'start' or 'open' are not valid methods for Session.
2fill in blank
medium

Complete the code to create a DataFrame from a table named 'EMPLOYEES'.

Snowflake
df = session.table([1])
Drag options to blanks, or click blank then click option'
A"employees"
Bemployees
C"EMPLOYEES"
D'EMPLOYEES'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the table name without quotes causes a NameError.
Using single quotes with uppercase may cause case mismatch.
3fill in blank
hard

Fix the error in the code to filter rows where the 'AGE' column is greater than 30.

Snowflake
filtered_df = df.filter(df[[1]] > 30)
Drag options to blanks, or click blank then click option'
A"age"
B'AGE'
CAGE
D"AGE"
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted column names causes NameError.
Using lowercase 'age' when the column is uppercase causes errors.
4fill in blank
hard

Fill both blanks to select the 'NAME' column and sort the DataFrame by 'SALARY' descending.

Snowflake
result_df = df.select([1]).order_by([2].desc())
Drag options to blanks, or click blank then click option'
A"NAME"
Bdf["SALARY"]
Cdf["NAME"]
D"SALARY"
Attempts:
3 left
💡 Hint
Common Mistakes
Passing column names as strings directly to select causes errors.
Using string 'SALARY' without df[] for order_by causes errors.
5fill in blank
hard

Fill all three blanks to create a new column 'BONUS' as 10% of 'SALARY', filter rows where 'BONUS' is greater than 5000, and show the result.

Snowflake
from snowflake.snowpark.functions import col

result = df.with_column("BONUS", [1]).filter([2] > 5000)
result.[3]()
Drag options to blanks, or click blank then click option'
Acol("SALARY") * 0.1
Bcol("BONUS")
Cshow
Dcollect
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'SALARY' as a string instead of col("SALARY") in calculations.
Filtering on 'BONUS' without using col() causes errors.
Using collect() instead of show() to display results.