Operator Precedence Rules in Ruby

Descrição

Think you know operator precedence rules? Test yourself on operator precedence rules in ruby with this short quiz.
Domhnall Murphy
Quiz por Domhnall Murphy, atualizado more than 1 year ago
Domhnall Murphy
Criado por Domhnall Murphy mais de 3 anos atrás
2473
0

Resumo de Recurso

Questão 1

Questão
What is the output from the following ruby statement: puts (1 + 2 * 2)
Responda
  • 5
  • 6
  • 3
  • 4

Questão 2

Questão
What is the output from the following ruby statement: puts (4 * 6 / 2 * 2)
Responda
  • 6
  • 24
  • 3
  • 0

Questão 3

Questão
What is the output from the following ruby expression: puts (4 / 2 * 2 + 2 / 2)
Responda
  • 4
  • 2
  • 3
  • 5

Questão 4

Questão
What is the output from the following ruby statement: puts (5 + 10 % 3 + 6 / 2)
Responda
  • 9
  • 3
  • \(5 \frac{1}{2} \)
  • \(6 \frac{1}{2} \)

Questão 5

Questão
What is the output from the following ruby statement: puts (4 * 2 ** 2 * 2)
Responda
  • 32
  • 16
  • 128
  • 64

Questão 6

Questão
What is the output from the final ruby statement: c = 3 d = 4 puts (c or d == 7)
Responda
  • 3
  • true
  • false
  • 1

Questão 7

Questão
What is the output of the last ruby statement x = 5 && 4 puts x
Responda
  • true
  • false
  • 5
  • 4

Questão 8

Questão
What is the output of the last ruby statement x = 5 and 4 puts x
Responda
  • true
  • false
  • 5
  • 4

Questão 9

Questão
What is the output from the final ruby statement: a = false b = true ! a || b = false puts b
Responda
  • true
  • false
  • 0
  • 1

Questão 10

Questão
What is the output from the following ruby statement puts (13 & 10 << 1)
Responda
  • 4
  • 16
  • 5
  • 8

Questão 11

Questão
What is the output from the final ruby statement a = false b = true puts (a && b ? 'foo' : 'bar')
Responda
  • true
  • false
  • foo
  • bar

Questão 12

Questão
What is the output from the final ruby statement a = false b = true puts (a and b ? 'foo' : 'bar')
Responda
  • true
  • false
  • foo
  • bar

Semelhante

Ruby+Rails - Borrador
Carlos Ortiz Gutierrez
Operadores logicos en ruby on rails
Pablo Soto
Objetos mutables e inmutables
Benjamin Villalpando
Tools and resources for computational thinking
Miguel Salamanca
What is programming language? Why python?
51143
Eloquent JavaScript
Marco s
Maleta Didáctica "Ipiales te llevo en mi corazón"
alejalove1708
HIPERTEXTO
RUBY PEÑALOZA
Condiciones Ruby on rails
Pablo Soto
RUBY
nangas_94
Parámetros Curriculares para la educación indígena
kawaii-sweet