[ AEEP2301 ] 2 3 4 - Literals, Operators, Variables

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/54

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:54 AM on 9/12/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

55 Terms

1
New cards

A literal is data which has a fixed value within itself.

What is a literal?

2
New cards

Because 2 is a literal, while hello is treated as a variable name.

Why does print(hello) give an error but print(2) does not?

3
New cards

A literal can be placed inside the parentheses.

What can be placed inside the parentheses of print() to produce an output?

4
New cards

Because Python stores and treats different types of literals differently.

Why are different types of literals treated differently in Python?

5
New cards

Integers, floating-point numbers, strings, and Boolean values.

What are the four types of literals covered in Lab 2?

6
New cards

A whole number, both positive and negative, including 0.

What is an integer?

7
New cards

Underscores can be used to improve readability of very large numbers without changing the value.

How can underscores be used with large integers?

8
New cards

It represents the integer 11111.

What does 11_111 represent?

9
New cards

Put a minus (-) sign before the number.

How do you indicate a negative integer in Python?

10
New cards

No. A positive sign is not necessary, although it can be used.

Is a positive sign required for a positive number?

11
New cards

Only 0 and 1.

What digits are used in binary numbers?

12
New cards

Write 0b or 0B, followed by the binary value.

What is the Python syntax for a binary number?

13
New cards

Numbers from 0 to 7.

What numbers can be used in an octal number?

14
New cards

Write 0o or 0O, followed by the octal value.

What is the Python syntax for an octal number?

15
New cards

0–9 and A–F.

What characters can be used in hexadecimal numbers?

16
New cards

Write 0x or 0X, followed by the hexadecimal value.

What is the Python syntax for a hexadecimal number?

17
New cards

Manual conversions.

What should you study regarding binary, octal, and hexadecimal for quizzes/exams?

18
New cards

A number which has a decimal point.

What is a floating-point number?

19
New cards

4.0

What does Python output for 4.?

20
New cards

0.7

What does Python output for .7?

21
New cards

e or E.

What letter is used for scientific notation in Python?

22
New cards

It represents the exponent.

What does the e represent in scientific notation?

23
New cards

Put a minus (-) sign before the exponent value.

How do you write a negative exponent in scientific notation?

24
New cards

6.637e+34

What is the output of print(6.637e34)?

25
New cards

Text enclosed in inverted commas.

What is a string?

26
New cards

True and False.

What are the two Boolean values?

27
New cards

True = 1 and False = 0.

What numerical values are associated with True and False?

28
New cards

They are reserved keywords.

What are True and False classified as in Python?

29
New cards

The output is a floating-point number.

What happens when an integer and a floating-point number are added?

30
New cards

A unary operation involves one number, while a binary operation involves two numbers.

What is the difference between a unary and binary operator?

31
New cards

Unary.

Is -5 unary or binary?

32
New cards

Binary.

Is 5 - 3 unary or binary?

33
New cards

The output will be a floating point.

What happens when at least one input is a floating point for addition, subtraction, or multiplication?

34
New cards

A floating-point number.

What type of output does / always produce?

35
New cards

//

What operator is used for integer/floor division?

36
New cards

Because // is floor division, which gives the lower value.

Why does 6 // 4 equal 1 instead of 2?

37
New cards

It gives 1, because it takes the lower value.

What does floor division do with 1.999?

38
New cards

A float.

If at least one input is a float in floor division, what type is the answer?

39
New cards

Because floor division takes the value toward negative infinity, and -2 is lower than -1.

Why does -6 // 4 equal -2?

40
New cards

The remainder after division.

What does the modulus operator return?

41
New cards

No. It calculates the remainder.

Does % calculate percentages?

42
New cards

3.0

What is 12 % 4.5?

43
New cards

The result will be a float.

What happens if at least one input to % is a float?

44
New cards

( ) → ** → unary + - → / // * % → binary + -

What is the order of operator precedence covered in Lab 2?

45
New cards

Left-side binding.

Do operators normally have left-side or right-side binding?

46
New cards

Exponentiation (**).

Which operator is the exception and starts from the right?

47
New cards

From the right, so it is 2 ** (2 ** 3).

How is 2 ** 2 ** 3 evaluated?

48
New cards

-9

What is the result of print(-3 ** 2)?

49
New cards

Because exponentiation has higher priority than the unary minus, so 3 ** 2 is calculated first, then the negative sign is applied.

Why is print(-3 ** 2) equal to -9 and not 9?

50
New cards

A value that can change and is used for storing data.

What is a variable?

51
New cards

variable_name = variable

What is the general syntax for creating a variable?

52
New cards

A variable can store any type of data/literal, including strings and integers.

What types of data can a variable store?

53
New cards

var = 1

var = var + 1

The existing variable is increased by 1, so var becomes 2.

What happens in this code?

54
New cards
  • Can contain letters (A-Z)

  • Can contain numbers (0-9)

  • Can contain underscores (_)

  • Cannot contain spaces or other special characters

  • Cannot use reserved keywords

  • Cannot start with a number

  • Should preferably start with a letter


What are the rules for naming variables in Python?

55
New cards

You have to declare it (X = Y).

What’s the first step in creating a variable?