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

Kursusindhold

Introduction to Python | Mobile-Friendly

Introduction to Python | Mobile-Friendly

1. Python Basics
2. Variables
3. Strings

book
Numbers

In the previous chapters, you operated with numbers. There are many variants of number classifications in math (negative/positive, rational/irrational, etc.). How does Python distinguish between numbers? There are three numerical types in Python:

  • float - represents a floating-point number

  • int - represents an integer/whole number

  • complex - represents a complex number

We won’t focus too much on complex numbers, since this is a branch of Further Mathematics. To get the type of a certain value/variable, use the type() function. For example, let's output the types of the numbers 5 and 10.5.

123456
# Creating the variables number1 = 5 number2 = 10.5 # Output the types of numbers print(type(number1)) print(type(number2))
copy
question mark

Which of the following answers is not a Python numerical type?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 7

Spørg AI

expand
ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

course content

Kursusindhold

Introduction to Python | Mobile-Friendly

Introduction to Python | Mobile-Friendly

1. Python Basics
2. Variables
3. Strings

book
Numbers

In the previous chapters, you operated with numbers. There are many variants of number classifications in math (negative/positive, rational/irrational, etc.). How does Python distinguish between numbers? There are three numerical types in Python:

  • float - represents a floating-point number

  • int - represents an integer/whole number

  • complex - represents a complex number

We won’t focus too much on complex numbers, since this is a branch of Further Mathematics. To get the type of a certain value/variable, use the type() function. For example, let's output the types of the numbers 5 and 10.5.

123456
# Creating the variables number1 = 5 number2 = 10.5 # Output the types of numbers print(type(number1)) print(type(number2))
copy
question mark

Which of the following answers is not a Python numerical type?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 7
Vi beklager, at noget gik galt. Hvad skete der?
some-alt