Data Types


5 min.   |   Beginner  

int

Integers int represent whole numbers, either positive or negative.

float

Floating-point numbers float represent decimal values, either positive or negative.

bool

Booleans bool represent True or False values, often used in conditionals.

str

Strings str are sequences of Unicode characters.

None

The value None represents the absence of a value.

Data Types: Exercises

Tip Data Types: Exercise 1

Calculate the slope from these two points (2, 3) and (5, 11).

Tip Data Types: Exercise 2

Calculate the percentage change if price goes from 120\$ to 150\$ (answer should be in decimal format; i.e. 0.3 for 30\% )

Tip Data Types: Exercise 3

A student has grades: 80 (weight 30\%), 90 (weight 50\%), 70 (weight 20\%). Calculate the grade of the student.

Tip Data Types: Exercise 4

Two independent events A and B have probabilities P(A)=0.3 and P(B)=0.5. Calculate the probability that both events occur P(A \cap B).

Tip Data Types: Exercise 5

A population of 1000 grows at 5\% per year, compounded annually. Calculate population after 3 years using:

P = P_{0}*(1 + r)^t