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

bookSubtraction

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.

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
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)
Tehtävä

Swipe to start coding

You have 2 numbers, subtract them.

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 7
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

Awesome!

Completion rate improved to 3.85

bookSubtraction

Pyyhkäise näyttääksesi valikon

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.

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
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)
Tehtävä

Swipe to start coding

You have 2 numbers, subtract them.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

close

Awesome!

Completion rate improved to 3.85
Osio 1. Luku 7
single

single

some-alt