Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Subtraction | Numeric Types
Python Data Types

book
Subtraction

In Python, we can subtract objects that are numeric types: complex numbers, integers, and floating point numbers. It's time to look at the example.

python
Input:
num_1 = 5
num_2 = 34.5
subtraction = num_1 - num_2

print(f'The subtraction of {num_1} and {num_2} is {subtraction}')

Output:
The subtraction of 5 and 34.5 is -29.5
python
Input:
num_1 = 43.6 + 7j
num_2 = 6.5 + 5j
subtraction = num_1 - num_2

print(f'The subtraction of {num_1} and {num_2} is {subtraction}')

Output:
The subtraction of (43.6+7j) and (6.5+5j) is (37.1+2j)
Oppgave

Swipe to start coding

You have 2 numbers, subtract them.

Løsning

a = 5 + 245j
b = 653.54
subtraction = a - b

print(f'The subtract is {subtraction}')

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 7
a = 5 + 245j
b = 653.54
subtraction = _ _ _

print(f'The subtract is {_ _ _} ')

Spør AI

expand
ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

some-alt