Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Converting | Variables
Introduction to Python | Mobile-Friendly
course content

Kurssisisältö

Introduction to Python | Mobile-Friendly

Introduction to Python | Mobile-Friendly

1. Python Basics
2. Variables
3. Strings

book
Converting

Suppose you want to change the type of a certain number. Use the eponymous function to convert a number into a float, int, or complex type. For example, if you convert a float number to an int, the decimal part will simply be removed.

12345
# Create a variable with float number float_number = 4.8 # Convert it into integer and output int_number = int(float_number) print(int_number)
copy

Note that converting into an integer is not the same as rounding. The number from the example above, according to math, would be rounded to 5, but we got 4.

Perform an integer division of 231 by 17 without using the // operator.

question-icon

Fill in the blanks to complete the task.

print()
13

Click or drag`n`drop items and fill in the blanks

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 8

Kysy tekoälyä

expand
ChatGPT

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

course content

Kurssisisältö

Introduction to Python | Mobile-Friendly

Introduction to Python | Mobile-Friendly

1. Python Basics
2. Variables
3. Strings

book
Converting

Suppose you want to change the type of a certain number. Use the eponymous function to convert a number into a float, int, or complex type. For example, if you convert a float number to an int, the decimal part will simply be removed.

12345
# Create a variable with float number float_number = 4.8 # Convert it into integer and output int_number = int(float_number) print(int_number)
copy

Note that converting into an integer is not the same as rounding. The number from the example above, according to math, would be rounded to 5, but we got 4.

Perform an integer division of 231 by 17 without using the // operator.

question-icon

Fill in the blanks to complete the task.

print()
13

Click or drag`n`drop items and fill in the blanks

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 8
Pahoittelemme, että jotain meni pieleen. Mitä tapahtui?
some-alt