Arithmetic, relational and Boolean operators. String functions: length, substring, upper, lower, charAt. Core Paper 1 skills.
+ addition, - subtraction, * multiplication, / division.MOD — remainder after integer division. 7 MOD 3 = 1. 10 MOD 2 = 0 (even test).DIV — integer (whole-number) division. 7 DIV 3 = 2 (discard remainder).^ or ** — exponentiation (power). 2^3 = 8.== equal to. != not equal to.< less than. > greater than.<= less than or equal to. >= greater than or equal to.IF score >= 50 THENAND — both conditions must be True. (x > 0) AND (x < 10)OR — at least one condition must be True. (grade == "A") OR (grade == "B")NOT — reverses Boolean. NOT (x == 0) is True when x is not 0.IF (age >= 18) AND (hasID == True) THENLEN(str) — returns number of characters. LEN("hello") = 5.SUBSTRING(str, start, length) — extract part of string. SUBSTRING("hello", 0, 3) = "hel".UPPER(str) — converts to uppercase. UPPER("hello") = "HELLO".LOWER(str) — converts to lowercase.str[i] — access character at index i (0-indexed). "hello"[0] = "h".+ operator. "Hello" + " " + "World" = "Hello World".name = "Ander"
PRINT LEN(name) // Output: 5
PRINT SUBSTRING(name, 0, 3) // Output: "And"
PRINT UPPER(name) // Output: "ANDER"
PRINT name[0] // Output: "A"
// Checking first character
IF UPPER(name[0]) == "A" THEN
PRINT "Name starts with A"
END IF
// String concatenation
greeting = "Hello, " + name + "!"
PRINT greeting // Output: "Hello, Ander!"// MOD: remainder
PRINT 10 MOD 3 // Output: 1
PRINT 8 MOD 2 // Output: 0 (so 8 is even)
// DIV: integer division
PRINT 17 DIV 5 // Output: 3
PRINT 17 MOD 5 // Output: 2 (17 = 3*5 + 2)
// Test if number is even
IF num MOD 2 == 0 THEN
PRINT "Even"
ELSE
PRINT "Odd"
END IFWhat is the result of 17 MOD 5?
What does LEN("Computing") return?
A variable word is assigned the value "Python". Write pseudocode to: (a) print the first 3 characters, (b) print the string in uppercase, (c) print the last character. (3 marks)
Write pseudocode for a program that: asks the user for a number, then prints "Fizz" if divisible by 3, "Buzz" if divisible by 5, "FizzBuzz" if divisible by both, otherwise prints the number. (4 marks)
What is the result of: (5 > 3) AND (10 < 8)?