Quizzes and the daily puzzle

Test yourself: a new puzzle every day and eight quizzes by language. Results and your streak are kept in your browser.

Daily puzzle

What does this code print? Pick an answer.

Python
print(list(range(1, 5)))

Quizzes

Python: basics

8 questions, about 3 min

Questions and answers
  1. What does `print(7 // 2)` print?
    • 3 ✓
    • 3.5
    • 4
    • 2

    The `//` operator is floor division: the fractional part is dropped.

  2. Which literal creates a list?
    • (1, 2, 3)
    • {1, 2, 3}
    • {"a": 1}
    • [1, 2, 3] ✓

    Square brackets make a list. Parentheses make a tuple, curly braces make a set or a dict.

  3. What does `for i in range(3): print(i)` print?
    • 1, 2, 3
    • 0, 1, 2, 3
    • 0, 1, 2 ✓
    • 1, 2

    `range(3)` starts at zero and does not include 3.

  4. Which keyword defines a function?
    • function
    • def ✓
    • func
    • fn

    Python defines functions with `def`.

  5. What does `d["a"]` return if `d = {"a": 1}`?
    • 1 ✓
    • "a"
    • KeyError
    • None

    Indexing a dict by key returns the value stored under it.

  6. What does `nums.append(4)` do to `nums = [1, 2, 3]`?
    • Adds 4 to the start
    • Replaces all items with 4
    • Removes 4 from the list
    • Adds 4 to the end: [1, 2, 3, 4] ✓

    `append` changes the same list and puts the item at the end.

  7. What does `print("ab" * 3)` print?
    • ab3
    • ab ab ab
    • ababab ✓
    • An error

    Multiplying a string by a number repeats it.

  8. What does `print(type(5 / 2))` print?
    • <class 'int'>
    • <class 'float'> ✓
    • <class 'str'>
    • <class 'double'>

    Regular division `/` always gives a float, even when it divides evenly.

JavaScript: basics

8 questions, about 3 min

Questions and answers
  1. Which keyword declares a variable that cannot be reassigned?
    • var
    • const ✓
    • let
    • final

    `const` forbids reassignment. JavaScript has no `final` keyword.

  2. What does `console.log("5" + 3)` print?
    • 53 ✓
    • 8
    • NaN
    • An error

    If one operand is a string, `+` concatenates: the number becomes a string.

  3. Which method adds an item to the end of an array?
    • pop
    • shift
    • unshift
    • push ✓

    `push` adds at the end, `pop` removes from the end, `unshift` adds at the start, `shift` removes from the start.

  4. What does `3 === "3"` give?
    • true
    • undefined
    • false ✓
    • An error

    `===` compares without type conversion, and a number and a string are different types.

  5. What does `let a; console.log(typeof a);` print?
    • null
    • undefined ✓
    • object
    • string

    A variable with no value is `undefined`, and its type is also "undefined".

  6. What does `f(2, 3)` return for `const f = (a, b) => a + b;`?
    • 5 ✓
    • 23
    • undefined
    • 6

    An arrow function without braces returns the value of the expression `a + b`.

  7. How many times does the body of `for (let i = 0; i < 3; i++)` run?
    • 2
    • 4
    • Forever
    • 3 ✓

    `i` takes 0, 1, 2, and at 3 the condition is false.

  8. What does `[1, 2, 3].map(n => n * 2)` return?
    • [1, 2, 3]
    • 12
    • [2, 4, 6] ✓
    • [2, 4]

    `map` builds a new array by applying the function to every item.

HTML: basics

8 questions, about 3 min

Questions and answers
  1. Which tag gives the largest heading?
    • <head>
    • <header>
    • <h1> ✓
    • <title>

    Headings run from `<h1>` (most important) to `<h6>`.

  2. Which markup creates a link?
    • <link>page.html</link>
    • <a href="page.html">Link</a> ✓
    • <url="page.html">Link</url>
    • <a src="page.html">Link</a>

    A link is the `<a>` tag with an `href` attribute.

  3. Which `<img>` attribute holds the alternative text?
    • alt ✓
    • title
    • src
    • name

    Screen readers read `alt`, and it shows when the image fails to load.

  4. Which tag creates a bulleted list?
    • <ol>
    • <li>
    • <list>
    • <ul> ✓

    `<ul>` is a bulleted list, `<ol>` is numbered, `<li>` is a single item.

  5. What is `<!DOCTYPE html>` for?
    • It links a stylesheet
    • It creates the page title
    • It tells the browser this is a modern HTML document ✓
    • It adds a script

    Without it the browser may fall back to a compatibility mode for old pages.

  6. Which attribute makes an `<input>` field required?
    • mandatory
    • required ✓
    • must
    • needed

    The boolean attribute `required` blocks form submission while the field is empty.

  7. What does the `<br>` tag do?
    • Breaks the line ✓
    • Makes text bold
    • Creates a paragraph
    • Adds a horizontal line

    `<br>` is an empty tag that simply moves the text to a new line.

  8. Where does the visible page content go?
    • <head>
    • <meta>
    • <title>
    • <body> ✓

    `<head>` holds service data, and everything the user sees lives in `<body>`.

CSS: basics

8 questions, about 3 min

Questions and answers
  1. Which selector picks elements with class `card`?
    • #card
    • card
    • *card
    • .card ✓

    A class is selected with a dot, an id with a hash.

  2. Which property sets the text color?
    • text-color
    • font-color
    • color ✓
    • foreground

    `color` sets the text color, and `background-color` sets the background.

  3. Which property sets the space inside an element, between content and border?
    • margin
    • padding ✓
    • gap
    • outline

    `padding` is inner space, `margin` is outer space.

  4. Which declaration makes an element a flex container?
    • display: flex; ✓
    • flex: container;
    • position: flex;
    • layout: flex;

    Children of a flex container can be aligned with `justify-content` and `align-items`.

  5. What does `/* text */` do in CSS?
    • Sets the font size
    • Includes a file
    • Ends the rule
    • It is a comment, the browser ignores it ✓

    Everything between `/*` and `*/` is a comment.

  6. For `<p class="a" id="b">` the rules `.a { color: red; }` and `#b { color: blue; }` apply. What color is the text?
    • Red
    • Black
    • Blue ✓
    • Depends only on line order

    An id selector has higher specificity than a class selector.

  7. Which declaration makes text bold?
    • text-style: bold;
    • font-weight: bold; ✓
    • font: bolder-text;
    • weight: 700;

    `font-weight` sets how thick the font is.

  8. What does `margin: 0 auto;` do to a block with a set width?
    • Centers it horizontally ✓
    • Centers it vertically
    • Makes it invisible
    • Stretches it over the whole screen

    Automatic side margins split the free space equally left and right.

SQL: basics

8 questions, about 3 min

Questions and answers
  1. Which query selects all columns of the `users` table?
    • SELECT * FROM users; ✓
    • GET ALL FROM users;
    • SELECT users;
    • SHOW * users;

    The asterisk after `SELECT` means all columns.

  2. Which keyword filters rows by a condition?
    • ORDER BY
    • GROUP BY
    • LIMIT
    • WHERE ✓

    `WHERE` keeps only the rows that satisfy the condition.

  3. Which clause sorts the result?
    • SORT BY
    • GROUP BY
    • ORDER BY ✓
    • ARRANGE

    `ORDER BY name DESC` sorts by name in reverse order.

  4. What does `SELECT COUNT(*) FROM users;` return?
    • All user names
    • The number of rows in the table ✓
    • The largest id
    • The number of columns

    `COUNT(*)` counts rows.

  5. What does `INNER JOIN` return?
    • Only rows that have a match in both tables ✓
    • All rows of the left table
    • All rows of both tables
    • Rows without a match

    Unmatched rows are dropped by `INNER JOIN`. To keep them you need `LEFT JOIN`.

  6. Which keyword fills the gap: `SELECT city, COUNT(*) FROM users ___ city;`?
    • ORDER BY
    • WHERE
    • HAVING ONLY
    • GROUP BY ✓

    `GROUP BY` collects rows into groups, and `COUNT` is computed per group.

  7. Which query adds a new row?
    • ADD users (name) VALUES ('Ann');
    • UPDATE users SET name = 'Ann';
    • INSERT INTO users (name) VALUES ('Ann'); ✓
    • INSERT users = 'Ann';

    `INSERT INTO` adds a row, while `UPDATE` changes existing ones.

  8. How do you find rows where `email` is empty (NULL)?
    • WHERE email = NULL
    • WHERE email IS NULL ✓
    • WHERE email == NULL
    • WHERE email = ''

    NULL equals nothing, not even itself, so you test it with `IS NULL`.

Go: basics

8 questions, about 3 min

Questions and answers
  1. Which form declares a variable briefly inside a function?
    • x = := 5
    • x := 5 ✓
    • let x = 5
    • int x = 5

    `:=` declares the variable and infers its type from the value.

  2. What does `var n int; fmt.Println(n)` print?
    • 0 ✓
    • nil
    • undefined
    • A compile error

    Go variables get a zero value, which is 0 for `int`.

  3. Which loop keywords exist in Go?
    • `for` and `while`
    • `for`, `while` and `do`
    • Only `loop`
    • Only `for` ✓

    All Go loops use `for`: with a counter, with a condition or endless.

  4. How do you get the length of a slice `s`?
    • s.length
    • s.size()
    • len(s) ✓
    • count(s)

    The built-in function `len` gives the length.

  5. When is a function name visible from other packages?
    • When it starts with a lowercase letter
    • When it starts with an uppercase letter ✓
    • When it has `public` before it
    • It is always visible

    That is why `fmt.Println` starts with a capital letter.

  6. What does `defer` do?
    • Delays the call until the function returns ✓
    • Runs the function in a new thread
    • Skips the line
    • Breaks the loop

    Deferred calls are handy for closing files and other resources.

  7. What does `m["x"]` return if a `map[string]int` has no key "x"?
    • nil
    • A panic
    • A compile error
    • 0 ✓

    A missing key gives the type's zero value, and the form `v, ok := m["x"]` lets you check.

  8. What happens if you declare a local variable and never use it?
    • Only a warning
    • Nothing
    • A compile error ✓
    • A runtime error

    Go refuses to compile code with an unused local variable.

Java: basics

8 questions, about 3 min

Questions and answers
  1. Which signature is the entry point of a Java program?
    • public void main()
    • static int start(String[] args)
    • public static void main(String[] args) ✓
    • void run(String[] args)

    The JVM looks for a `main` method with exactly this signature.

  2. What does `System.out.println(5 / 2);` print?
    • 2.5
    • 2 ✓
    • 3
    • 2.0

    Dividing two ints gives an int, the fractional part is dropped.

  3. How do you correctly compare the contents of two strings?
    • a.equals(b) ✓
    • a == b
    • a = b
    • a.same(b)

    `==` compares object references, while `equals` compares the text.

  4. How do you get the length of an array `arr`?
    • arr.length()
    • arr.size()
    • len(arr)
    • arr.length ✓

    An array has a `length` field without parentheses. `length()` belongs to String, `size()` to collections.

  5. What value does an element of `new int[3]` have right after creation?
    • null
    • -1
    • 0 ✓
    • Undefined garbage

    Elements of an int array are initialized to zeros.

  6. Which of these types is not a primitive?
    • int
    • String ✓
    • double
    • boolean

    `String` is a class, while `int`, `double` and `boolean` are primitives.

  7. In which file must `public class Main` live?
    • Main.java ✓
    • main.java
    • Program.java
    • Main.class

    The file name must match the public class name, case included.

  8. What happens with `final int x = 5; x = 6;`?
    • x becomes 6
    • x stays 5 without an error
    • An error only at run time
    • A compile error ✓

    `final` forbids changing the value after the first assignment.

Git: basics

8 questions, about 3 min

Questions and answers
  1. Which command creates a new repository in the current folder?
    • git new
    • git start
    • git create
    • git init ✓

    `git init` creates the hidden `.git` folder.

  2. Which command stages changes for the next commit?
    • git push
    • git stage-all
    • git add ✓
    • git save

    `git add` puts the changes into the staging area.

  3. How do you make a commit with a message?
    • git save "Fix bug"
    • git commit -m "Fix bug" ✓
    • git push -m "Fix bug"
    • git add -m "Fix bug"

    The `-m` flag passes the commit message right in the command.

  4. Which command shows which files changed and what is staged?
    • git status ✓
    • git log
    • git show-all
    • git diff-names

    `git status` shows the state of the working folder and the index.

  5. Which command creates branch `feature` and switches to it?
    • git branch -d feature
    • git merge feature
    • git new feature
    • git switch -c feature ✓

    The `-c` flag creates the branch. `git checkout -b feature` does the same.

  6. Which command copies a remote repository to your computer?
    • git pull-all
    • git fork
    • git clone ✓
    • git download

    `git clone` downloads the whole history and creates a local copy.

  7. Which command sends your commits to the remote server?
    • git pull
    • git push ✓
    • git fetch
    • git send

    `push` sends, while `pull` and `fetch` bring changes from the remote.

  8. What does `git merge feature` do while you are on `main`?
    • Brings the changes from `feature` into `main` ✓
    • Deletes branch `feature`
    • Brings `main` into `feature`
    • Creates a copy of `main`

    Merging brings into the current branch what it does not have yet.

More in the Lab

Know the answer? Show it in the courses

Tasks earn XP and your streak grows.