0
0
Intro to Computingfundamentals~10 mins

Conditional logic (if-then decisions) in Intro to Computing - Interactive Code Practice

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

Complete the code to check if a number is positive.

Intro to Computing
if number [1] 0:
    print("Positive number")
Drag options to blanks, or click blank then click option'
A<
B>
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' will check for negative numbers.
Using '==' checks only if the number is exactly zero.
2fill in blank
medium

Complete the code to print "Even" if the number is divisible by 2.

Intro to Computing
if number [1] 2 == 0:
    print("Even")
Drag options to blanks, or click blank then click option'
A//
B+
C%
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' or '*' instead of '%' will not check divisibility.
Using '//' gives the quotient, not the remainder.
3fill in blank
hard

Fix the error in the code to check if a number is negative.

Intro to Computing
if number [1] 0:
    print("Negative number")
Drag options to blanks, or click blank then click option'
A>=
B>
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' checks for positive numbers instead.
Using '==' checks only if the number is zero.
4fill in blank
hard

Fill in the blank to print "Adult" if age is 18 or older.

Intro to Computing
if age [1] 18:
    print("Adult")
Drag options to blanks, or click blank then click option'
A>=
B<
Cand
Dor
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>=' will check the wrong condition.
Using 'and' or 'or' incorrectly can cause logic errors.
5fill in blank
hard

Fill all three blanks to create a dictionary of words and their lengths for words longer than 3 characters.

Intro to Computing
lengths = [1]: [2] for [3] in words if len([3]) > 3
Drag options to blanks, or click blank then click option'
Aword
Blen(word)
Dw
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Putting the length function in the wrong place.