Skip to content

Practice: Variables

Julia Ogris edited this page Aug 18, 2023 · 27 revisions

Q1.1

What is the type of variable s?

s:bool
s = true
print s

Choose one correct answer:

  • A: true
  • B: bool
  • C: false
  • D: program errors
  • E: none of the above
Solution B

Q1.2

What is the type of variable s?

s:string
s = true
print s

Choose one correct answer:

  • A: true
  • B: string
  • C: bool
  • D: program errors
  • E: none of the above
Solution D

Q1.3

What is the type of variable s?

s:string
s = "true"
print s

Choose one correct answer:

  • A: true
  • B: string
  • C: bool
  • D: program errors
  • E: none of the above
Solution B

Q1.4

What is the type of variable s?

s:num
s = 3
print s

Choose one correct answer:

  • A: number
  • B: 3
  • C: string
  • D: program errors
  • E: none of the above
Solution E

Q1.5

What is the type of variable s?

s = 3
s:num
print s

Choose one correct answer:

  • A: number
  • B: 3
  • C: string
  • D: program errors
  • E: none of the above
Solution D

Q2.1

What is the type of variable s?

s = 3
print s

Choose one correct answer:

  • A: num
  • B: 3
  • C: string
  • D: program errors
  • E: none of the above
Solution D

Q2.2

What is the type of variable s?

s := 3
print s

Choose one correct answer:

  • A: num
  • B: 3
  • C: string
  • D: program errors
  • E: none of the above
Solution A

Q2.3

What is the type of variable s?

s = "3"
print s

Choose one correct answer:

  • A: num
  • B: 3
  • C: string
  • D: program errors
  • E: none of the above
Solution D

Q2.4

What is the type of variable s?

s := "3"
print s

Choose one correct answer:

  • A: num
  • B: 3
  • C: string
  • D: program errors
  • E: none of the above
Solution C

Q2.5

What is the type of variable s?

s = true
print s

Choose one correct answer:

  • A: bool
  • B: 3
  • C: string
  • D: program errors
  • E: none of the above
Solution D

Q2.6

What is the type of variable s?

s := true
print s

Choose one correct answer:

  • A: bool
  • B: true
  • C: string
  • D: program errors
  • E: none of the above
Solution A

Q3.1

What is the type of variable s?

s:string
s := "abc"
print s

Choose one correct answer:

  • A: bool
  • B: "abc"
  • C: string
  • D: program errors
  • E: none of the above
Solution D

Q3.2

What is the type of variable s?

s:string
s = "abc"
print s

Choose one correct answer:

  • A: bool
  • B: "abc"
  • C: string
  • D: program errors
  • E: none of the above
Solution C

Q3.3

What is the type of variable s?

s := "abc"
s = "123"
print s

Choose one correct answer:

  • A: bool
  • B: "abc"
  • C: string
  • D: program errors
  • E: none of the above
Solution C

Q3.4

What is the type of variable s?

s := "abc"
s := "123"
print s

Choose one correct answer:

  • A: bool
  • B: "abc"
  • C: string
  • D: program errors
  • E: none of the above
Solution D

Q3.5

What is the type of variable s?

s = "abc"
s := "123"
print s

Choose one correct answer:

  • A: bool
  • B: "abc"
  • C: string
  • D: program errors
  • E: none of the above
Solution D

Q4.1

What does this program output?

s := "false"
print s s

Choose one correct answer:

  • A:

    s s
    
  • B:

    false false
    
  • C:

    "s s"
    
  • D: program errors

  • E: none of the above

Solution B

Q4.2

What does this program output?

s := true
print s s

Choose one correct answer:

  • A:

    s s
    
  • B:

    true true
    
  • C:

    "s s"
    
  • D: program errors

  • E: none of the above

Solution B

Q4.3

What does this program output?

s:bool
print s s

Choose one correct answer:

  • A:

    s s
    
  • B:

    false false
    
  • C:

    "s s"
    
  • D: program errors

  • E: none of the above

Solution B

Q4.4

What does this program output?

s:bool
s = true
print s s

Choose one correct answer:

  • A:

    s s
    
  • B:

    true true
    
  • C:

    "s s"
    
  • D: program errors

  • E: none of the above

Solution B

Q4.5

What does this program output?

s := true
s = true
print s s

Choose one correct answer:

  • A:

    s s
    
  • B:

    true true
    
  • C:

    "s s"
    
  • D: program errors

  • E: none of the above

Solution B

Q4.6

What does this program output?

s:num
print s s

Choose one correct answer:

  • A:

    s s
    
  • B:

    0 0
    
  • C:

    "s s"
    
  • D: program errors

  • E: none of the above

Solution B

Q4.7

What does this program output?

s := 2
print s s

Choose one correct answer:

  • A:

    s s
    
  • B:

    2 2
    
  • C:

    "s s"
    
  • D: program errors

  • E: none of the above

Solution B

Q5.1

Which drawing does this program create?

c2 := "red"
c1 := "blue"
w1 := 2
w2 := 5

color c1
width w1
move 20 80
line 80 80

color c2
move 20 60
line 80 60

width w2
move 20 40
line 80 40

color c1
move 20 20
line 80 20

Choose one correct answer:

  • A:
    lines-1
  • B:
    lines-2
  • C:
    lines-3
  • D:
    lines-4
  • E:
    lines-5
Solution A

Q5.2

Which drawing does this program create?

c2 := "red"
c1 := "blue"
w1 := 2
w2 := 5

color c1
width w1
move 20 80
line 80 80

width w2
move 20 60
line 80 60

color c2
move 20 40
line 80 40

width w1
move 20 20
line 80 20

Choose one correct answer:

  • A:
    lines-1
  • B:
    lines-2
  • C:
    lines-3
  • D:
    lines-4
  • E:
    lines-5
Solution B

Q5.3

Which drawing does this program create?

c1 := "red"
c2 := "blue"
w1 := 2
w2 := 5

color c1
width w1
move 20 80
line 80 80

width w2
move 20 60
line 80 60

color c2
move 20 40
line 80 40

width w1
move 20 20
line 80 20

Choose one correct answer:

  • A:
    lines-1
  • B:
    lines-2
  • C:
    lines-3
  • D:
    lines-4
  • E:
    lines-5
Solution C

Q5.4

Which drawing does this program create?

c1 := "red"
c2 := "blue"
w1 := 2
w2 := 5

color c1
width w1
move 20 80
line 80 80

width w2
move 20 60
line 80 60

color c2
move 20 20
line 80 20

width w1
move 20 40
line 80 40

Choose one correct answer:

  • A:
    lines-1
  • B:
    lines-2
  • C:
    lines-3
  • D:
    lines-4
  • E:
    lines-5
Solution D

Q5.5

Which drawing does this program create?

c1 := "red"
c2 := "blue"
w1 := 2
w2 := 5

color c1
width w1
move 20 60
line 80 60

width w2
move 20 80
line 80 80

color c2
move 20 20
line 80 20

width w1
move 20 40
line 80 40

Choose one correct answer:

  • A:
    lines-1
  • B:
    lines-2
  • C:
    lines-3
  • D:
    lines-4
  • E:
    lines-5
Solution E

Q6.1

Which program creates the following output?

true false

Choose three correct answers:

  • A:

    x1 := true
    x2 := false
    print x1 x2
    
  • B:

    b:bool
    print "true" b
    
  • C:

    x1:string
    x1 = "true"
    x2 := "false"
    print x1 x2
    
  • D:

    x1:string
    x1 := "true"
    x2 := false
    print x1 x2
    
Solution A,B,C

Q6.2

Which program creates the following output?

1 0

Choose three correct answers:

  • A:

    x1:num
    x2 := 1
    print x1 x2
    
  • B:

    x2:num
    x1 := 1
    print x1 x2
    
  • C:

    x1 := "1"
    x2 := 0
    print x1 x2
    
  • D:

    x1 := "1"
    x2:num
    print x1 x2
    
Solution B,C,D

Q6.3

Which program creates the following output?

0 false

Choose three correct answers:

  • A:

    x1:num
    x2 := false
    print x1 x2
    
  • B:

    x1:num
    x2:bool
    print x1 x2
    
  • C:

    x1:num
    x2 := " false "
    print x1 x2
    
  • D:

    x1:num
    x2 := "false"
    print x1 x2
    
Solution A,B,D

Q6.4

Which program creates the following output?

0 true

Choose three correct answers:

  • A:

    x1:num
    x2 := true
    print x1 x2
    
  • B:

    x1:num
    x2:bool
    print x1 x2
    
  • C:

    x1:num
    x2 := "true"
    print x1 x2
    
  • D:

    x1 := "0"
    x2 := "true"
    print x1 x2
    
Solution A,C,D

Q7.1

Which program creates this drawing ?

squares

Choose two correct answers:

  • A:

    w := 30
    w2 := 10
    rect w w
    rect w w
    rect w2 w2    
    
  • B:

    w := 30
    w2 := 10
    rect w w
    rect w2 w2
    rect w w    
    
  • C:

    w := 10
    move 30 30
    rect w w
    w = 30
    rect w w
    move 0 0
    rect w w
    
  • D:

    w := 10
    w2 = 30
    rect w2 w2
    rect w w
    rect w2 w2
    
Solution B,C

Q7.2

Which program creates this drawing ?

squares

Choose two correct answers:

  • A:

    w1 := 20
    w2 := 40
    rect w1 w1
    rect w2 w2
    rect w1 w1
    
  • B:

    w := 20
    rect w w
    w = 40
    rect w w
    w = 20
    rect w w
    
  • C:

    w1 := 40
    w2 := 20
    rect w1 w1
    rect w2 w2
    rect w1 w1
    
  • D:

    w := 20
    rect w w
    w = 40
    rect w w
    w := 20
    rect w w
    
Solution A,B

Q7.3

Which program creates this drawing ?

lines

Choose two correct answers:

  • A:

    c := "red"
    c2 := "black"
    width 2
    color c2
    line 30 60
    color c
    line 60 20
    line 90 90
    
  • B:

    c := "red"
    c2 := "black"
    width 2
    color c2
    line 30 60
    color c
    line 60 20
    color c2
    line 90 90
    
  • C:

    c := "red"
    c2 := "black"
    width 2
    color c2
    line 30 60
    move 90 90
    line 60 20
    color c
    line 30 60
    
  • D:

    c := "red"
    c2 := "black"
    width 2
    color c2
    line 30 60
    move 90 90
    line 60 20
    color c
    line 30 50
    
Solution B,C

Q7.4

Which program creates this drawing ?

circles

Choose two correct answers:

  • A:

    c := "red"
    c2 := "black"
    p2 := 70
    move 70 50
    color c
    circle 30
    move p2 50
    color c2
    circle 30
    
  • B:

    c := "red"
    c2 := "black"
    move 70 50
    color c
    circle 30
    move 30 50
    color c2
    circle 30
    
  • C:

    x := 70
    r := 30
    move x 50
    color "red"
    circle r
    move r 50
    color "black"
    circle r
    
  • D:

    x := 70
    r := 30
    move x 50
    color "red"
    circle r
    move x 50
    color "black"
    circle r
    
Solution B,C

Q8.1

Add the missing line of code to create the output below:

a := "abc"
b:num
// --- missing line of code goes here ---
print a b

Output

abc 2.4

Missing line of code

Solution
b = 2.4

Q8.2

Add the missing line of code to create the output below:

b := 2.4
// --- missing line of code goes here ---
print a b

Output

abc 2.4

Missing line of code

Solution
a := "abc"

Q8.3

Add the missing line of code to create the output below:

a:string
a = "abc"
// --- missing line of code goes here ---
print a b

Output

abc 2.4

Missing line of code

Solution
b := 2.4

Q8.4

Add the missing line of code to create the output below:

a:string
b := 2.4
// --- missing line of code goes here ---
print a b

Output

abc 2.4

Missing line of code

Solution
a = "abc"