print() for Outputprint() function in Lua do?
print()?
print("Hello, World!")echo("Hello, World!")display("Hello, World!")log("Hello, World!")print("Lua", "is", "fun") output?
print() display numbers?
print() without arguments?
nilundefinedprintf()format()io.write()print()print() and io.write()?
print() adds a newline; io.write() does notio.write() adds a newline; print() does notprint()?
print("Lua", nil, "is great") output?
nil)nilprint() handle concatenated strings?
+ operator.. operator+ and ..io.read()io.read()?
read()io.input()io.read("*l")get_line()io.read() is used without any arguments?
io.read("*n") do?
io.read("*a")?
io.read() handle input redirection from a file?
io.input()io.open()io.read()?
stdout streamio.read()?
io.close()io.flush()input.close()io.read("*n") is used but the user enters a string?
nilio.read() read multiple inputs at once?
io.read("*l", "*n")string.format()io.format()printf()str.format()string.format("%.2n", num)string.format("%.2f", num)format(num, 2)format("0.2", num)string.format("%s", "Lua") return?
Lua%s Luastring%d represent in Lua?
%h%x%o%b%10s%10c%s10%-10sstring.format() than needed?
string.format("%d + %d = %d", 2, 3, 5)printf("%d + %d = %d", 2, 3, 5)io.write("%d + %d = %d", 2, 3, 5)log("%d + %d = %d", 2, 3, 5)string.format() be used for padding with zeros?
%0nd%zdstring.format()?
%-s%-10s%10s%<s| Qno | Answer |
|---|---|
| 1 | b) Displays output to the screen |
| 2 | a) print("Hello, World!") |
| 3 | c) Lua is fun (with spaces in between) |
| 4 | b) Yes, numbers are automatically converted to strings |
| 5 | b) It prints a blank line |
| 6 | d) print() |
| 7 | a) print() adds a newline; io.write() does not |
| 8 | b) No, it prints the memory address |
| 9 | b) Lua nil is great |
| 10 | b) Yes, using .. operator |
| 11 | b) To read input from the user |
| 12 | c) io.read("*l") |
| 13 | d) Waits for user input |
| 14 | a) Reads a number from the user |
| 15 | c) It reads all remaining input |
| 16 | b) Yes, with io.input() |
| 17 | a) The console (stdin) |
| 18 | a) io.close() |
| 19 | c) It returns nil |
| 20 | b) Yes, with a loop |
| 21 | a) string.format() |
| 22 | b) string.format("%.2f", num) |
| 23 | a) Lua |
| 24 | a) A decimal number |
| 25 | b) %x |
| 26 | a) %10s |
| 27 | b) Extra arguments are ignored |
| 28 | a) string.format("%d + %d = %d", 2, 3, 5) |
| 29 | b) Yes, using %0nd |
| 30 | b) %-10s |