Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the type of software license.
Intro to Computing
license_type = "GPL" print("The license is [1]")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the variable name, which prints the name instead of its value.
✗ Incorrect
The variable license_type holds the license name. Using it without quotes prints its value.
2fill in blank
mediumComplete the code to check if the license is 'MIT'.
Intro to Computing
if license == [1]: print("License is MIT")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around string literals causing errors or wrong comparisons.
✗ Incorrect
String values must be enclosed in quotes when compared in code.
3fill in blank
hardFix the error in the code to print 'Free software' if license is 'GPL'.
Intro to Computing
if license == [1]: print("Free software")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable name without quotes causing a NameError.
✗ Incorrect
The license name 'GPL' must be a string literal in quotes for comparison.
4fill in blank
hardFill the blank to create a dictionary of licenses and their types.
Intro to Computing
licenses = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using curly braces or missing quotes around strings.
✗ Incorrect
Option B provides the complete dictionary enclosed in braces with key-value pairs for licenses.
5fill in blank
hardFill all three blanks to filter licenses that are Open Source.
Intro to Computing
open_source = {k: v for k, v in licenses.items() if v [1] [2]
print(open_source.get([3], "Not found")) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators or wrong keys in get().
✗ Incorrect
The filter checks if the license type equals 'Open Source'. Then it prints the value for key 'MIT'.