Numbers Flashcards
Why is Python one of the most powerful languages when it comes to manipulating numerical data?
It is equipped with
-support for several types of numbers,
-along with utilities for performing computations on them.
Python’s utilities enable you to process and
analyze numerical data effectively.
CHAT GPT 3
Python provides tools and functions that allow you to carry out various mathematical calculations and operations on data.
These utilities help you manipulate numbers, perform mathematical operations like addition, subtraction, multiplication, division, and more complex tasks like trigonometric functions, logarithms, and statistical analysis.
In essence, Python’s utilities enable you to process and
analyze numerical data effectively.
What are the main types of numbers in Python?
The main types of numbers in Python are:
-Integers
-Floating-point numbers,
or FLOATS
-Complex numbers
Define Integers
The integer data type is comprised of all the positive and negative whole numbers.
Ex:
+8
-12
Define FLOATS or Floating-point numbers
FLOATS, refer to positive and negative decimal numbers.
Ex:
+1.23
-5.29
Define a complex number
Complex numbers are numbers made up of a real and an imaginary part.
Ex:
10+20j
2.5-18.2m
Write a code to print the following integers:
+9 and -15
print(9)
print(-15)
How do you assign an integer to a variable? code using 23, -199, +27, -34
How do you assign an integer to a variable?
- Code using 23, -199, +27, -34
num=123
print(num)
num=-16
print(num)
or
num = 123456789 # Assigning an integer to a variable
print(num)
num = -16000 # Assigning a new integer
print(num)
Create a code for the following numbers
1.34
-2.89
45.20
-3.16
print(1.00000000005) # A positive float
print(-85.6701) # A negative float
flt_pt = 1.23456789
print(flt_pt)
print(1.00000000005) # A positive float
print(-85.6701) # A negative float
flt_pt = 1.23456789
print(flt_pt)
Can you write a code that assigns a float to a variable? The floats will be:
[5, -3.14, 10, -2.71828, 7.5,]
[-2, 4.5, -10, 0.75, -6.2]
chatGPT:
Assigning ten mixed positive and negative numbers in a single line:
flt_pt = 1.23456789
print(flt_pt)
EX:
print(1.00000000005)
print(-85.6701)
flt_pt = 1.23456789
print(flt_pt)
Output:
1.00000000005
-85.6701
1.23456789
What is the template for making a complex number?
- complex(real, imaginary)
- print(complex(10, 20))
print(complex(2.5, -18.2))
complex_1 = complex(0, 2)
complex_2 = complex(2, 0)
print(complex_1)
print(complex_2)
-Output:
(10+20j)
(2.5-18.2j)
2j
(2+0j)
complex_1 = complex(0, 2)
complex_2 = complex(2, 0)
print(complex_1)
print(complex_2)
Output:
(10+20j)
(2.5-18.2j)
2j
(2+0j)