Basic Concepts Flashcards

(19 cards)

1
Q

In Python, what is used to output text?

A

In Python, we use the print statement to output text.

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

What does the print statement need to be followed by?

A

The print statement needs to be followed by parentheses, which enclose the output we want to generate.

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

What will the output of the following code be?

print ( ‘Hello world!’)

A

Hello world!

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

Fill in the blank to output “Hi”.

____(“Hi”)

A

print(“Hi”)

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

How can you get python to carry out a calculation?

A

Enter a calculation directly into the print statement

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

What will the output of this be:

print (2 + 2)
print (5+4-3)

A

4
6

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

How can you carry out multiplications and divisions in Python

A

Python also carries out multiplication and division, using an asterisk * to indicate multiplication and a forward slash / to indicate division.

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

What type of number does a single slash produce?

A

Using a single slash to divide numbers produces a decimal (or float, as it is called in programming).

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

What are floats used in Python to represent?

A

Floats are used in Python to represent numbers that aren’t integers (whole numbers).

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

Can computers store floats perfectly accurately?

A

Computers can’t store floats perfectly accurately, in the same way that we can’t write down the complete decimal expansion

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

How can you perform exponentials in Python?

A

This operation is performed using two asterisks.

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

Fill in the blank to output 5 raised to the 3rd power.

print(5___3)

A

print(5 ** 3)

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

How can you do floor division in Python?

A

Floor division is done using two forward slashes

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

What is floor division used to determine?

A

Floor division is used to determine the quotient of a division (the quantity produced by the division of two numbers).

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

What is the output of the following code?

print (20// 6)

A

3

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

How do you carry out the modulo operator?

A

The modulo operator is carried out with a percent symbol (%)

17
Q

What is the modulo operator used to give?

A

The modulo operator is used to get the remainder of a division.

18
Q

What is the output of the following code?

print (20 % 6)
print (1.25 % 0.5)

19
Q

What is the result of this code?

print (7%(5 // 2) )