What are Data Types and Variables? Flashcards

1
Q

What’s a data type?

A
  • The data type of an item is defined by the type and the range of values that an item can have.

-The data type of an item defines the type (integers, float, or complex numbers) and range of values (min to maximum) that item can have.

  • For example, if a variable is of the data type “integer,” it means that it can hold whole numbers (positive, negative, or zero) within a specific range defined for integers. Similarly, if a variable is of the data type “floating-point,” it can store decimal numbers within a certain range. Each data type has its own set of rules and limitations.
  • Data Type provides constraints and rules that help maintain data integrity and prevent unexpected behavior in programs.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What’s a variable?

A
  • a name to which a value / a data can be assigned.
  • variables allow us to give meaningful names to data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the 3 main data types
in Python?

A

Numbers

Strings

Booleans

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

3 Main type of numbers in Python:
1. Integers

A
  1. Integers: The integer data type is comprised of all the positive and negative whole numbers.

1 3000 -50 - 32560

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

3 Main type of numbers in Python:
2. Floating point number

A

Floating-point numbers, or floats, refer to positive and negative decimal numbers.

0.00034 4.87 -34.7400

In Python, 5 is considered to be an integer while 5.0 is a float.

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

3 Main type of numbers in Python:
3. Complex number

A

Numbers made up of a real and an imaginary part.

Just like theprint()statement is used to print values,complex()is used to create complex numbers.

It requires two values. The first one will be therealpart of the complex number, while the second value will be theimaginarypart.

Here’s the template for making a complex number:

complex(real,imaginary)

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