basics Flashcards

1
Q

exponentiation

A

**

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

variable

A

A variable is a named memory location. Think of a
variable as a box.
It contains a value. Think of the value as the
contents of the box.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the assignment statement r = 10 do?

A

It creates a variable r and assigns it the value of 10.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What can the first character of a variable name be?

A

It must be a letter (a-z, A-Z) or an underscore (_).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What characters can be used in the remaining part of a variable name?

A

Letters, numbers (0-9), and underscores (_)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Are variable names in Python case sensitive?

A

Yes, x and X are considered two different variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which of the following are valid variable names? radius, 1stValue, _value, Total$, data123

A

radius and _value are valid; 1stValue, Total$, and data123 are invalid.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

int

A

numbers as integers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

float

A

numbers as decimals

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

string

A

A string is a sequence of characters
enclosed within

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Given s = ‘The Beatles’, what is s[4]?

A

s[4] is ‘B’.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is string slicing?

A

Slicing allows you to extract a portion of a string by specifying a range of indices.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does t = s[4:8] return for s = ‘The Beatles’?

A

t becomes ‘Beat’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

print with operator

A

print(“Hello,” + “world”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

print with operator
username=”Lisa”

A

print(“Hello,” + username+ “!”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

print with f strings
username=”Lisa”

A

print(f”Hello,{Username} !”)

17
Q

\n

A

prints out a new line

18
Q

\t

A

prints out tab

19
Q

boolean

A

true or false

20
Q

What is a syntax error?

A

A syntax error refers to issues with the structure of a program, violating the rules of the programming language.

21
Q

When does the interpreter check for syntax errors?

A

The interpreter checks for syntax errors during the parsing stage before executing the code.

22
Q

What is a runtime error?

A

A runtime error occurs after the program has started running and typically indicates an exceptional situation.

23
Q

What is a logical error?

A

A logical error, also known as a semantic error, occurs when there is a mistake in the program’s logic, leading to incorrect results.