CS: Introduction to Python Flashcards

1
Q

What’s an interpreter?

A

An interpreter is a translator that takes a high-level language (source program) and converts it into machine code.

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

What are some important things to keep in mind about programming in Python?

A

Python is case sensitive, spacing is important, and error messages are helpful in helping you learn.

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

What’s a variable?

A

It’s a container in which data can be stored.

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

What will be the output?
x=4
x=”Noura”
print(x)

A

Noura

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

What are the rules for python variables?

A
  1. A variable name must start with a letter or underscore.
  2. A variable name cannot start with a number
  3. A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
  4. Variable names are case-sensitive
  5. The reserved words (keywords) cannot be used naming the variable.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are a few reserved keywords?

A

False, None, True, and, if, elif, else, not, or, while…

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

Can I name my variable “2Names”?

A

No, because variables can’t start with numbers.

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

Can I name my variable “_2Names”?

A

Yes, because variables can start with underscores.

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

Is this a valid way of assigning variables?
x, y, z = “A”, “B”, “C”

A

Yes

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

What are the different data types?

A

String (str), integer (int), float (float), boolean (bool), lists…

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

(Program) Create variables that input the user’s name, height, and citizenship status.

A

name = input(“Enter your name: “)
height = float(input(“Enter your height in meters: “))
citizenship_status = input(“Are you a citizen? (yes/no): “)
print(“User Information:”)
print(“Name:”, name)
print(“Height:”, height, “meters”)
print(“Citizenship Status:”, citizenship_status)

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

What is type casting?

A

Changing one variable data type into another.
ex: Age=int(Age)

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