Python # How to check type and type for super beginners

environment windows7 (I want a Mac Book Pro 16inch) Visual Studio Code chrome

This article is written for beginners in programming and Python.

  1. Python type type and how to check the type

integer 1 123 -1234

Etc. (integer). It includes both plus and minus.

style.py


print(type(1))
#<class 'int'>"It's an integer," he says.

print(type(123))
#<class 'int'>This is also an "integer"

print(type(-1234))
#<class 'int'>Even if it's negative, it's an integer.

string Hello Hello Python I'll be back Comment allez-vous? There are already many coronas

Etc. (character string).

type.py


print(type("Hello"))
#<class 'str'>Take the first three of string'str'.. In other words, it is a character (character string).

print(type("Hello Python"))
#<class 'str'>This is also a character string.

print(type("Comment allez-vous?"))
#<class 'str'>Even in French, "It's a character string"

print(type("There are already many coronas"))
#<class 'str'>The virus is also a "character string"

floating point numbers 1.0 -3.14

Decimal point (floating point number * 1)

type.py


print(type(1.0))
#<class 'float'>Take the 5 acronyms for floating point'float'.. In other words, it is a decimal point (floating point number).

print(type(-3.14))
#<class 'float'>Even if it is negative, it is a decimal point (floating point number).

complex numbers 3j 3.21j

Imaginary number. what the hell! When I try to google, here is difficult to understand, but it is written in an easy-to-understand manner.

type.py


print(type(3j))
# <class 'complex'>"Hey, it's an imaginary number!"

print(type(3.21j))
# <class 'complex'>"It's not Kyo on Hachijojima ... but an imaginary number."

boolean True (T is uppercase) Fals (F is uppercase) Fortunately, there are only two types of booleans. "I write Boolean and say Boolean."

type.py


print(type(True))
# <class 'bool'>"I'm a Boolean"

print(type(False))
# <class 'bool'>"I'm Takagi Boolean."

***


Recommended Posts

Python # How to check type and type for super beginners
How to convert Python # type for Python super beginners: str
How to convert Python # type for Python super beginners: int, float
Python for super beginners Python # dictionary type 1 for super beginners
Python for super beginners Python # dictionary type 2 for super beginners
How to learn TensorFlow for liberal arts and Python beginners
Python for super beginners Python for super beginners # Easy to get angry
How to make Python faster for beginners [numpy]
Python #function 2 for super beginners
Python for super beginners Python #functions 1
Python #list for super beginners
~ Tips for beginners to Python ③ ~
[For beginners] How to use say command in python!
[For beginners] How to study Python3 data analysis exam
Python #len function for super beginners
Python #Hello World for super beginners
[Python] How to write type annotations for Callable objects treated as variables and arguments
How to package and distribute Python scripts
How to install and use pandas_datareader [Python]
Let's put together Python for super beginners
[Python] Organizing how to use for statements
How to check opencv version in python
[For beginners] How to register a library created in Python in PyPI
python: How to use locals () and globals ()
How to use "deque" for Python data
[Python] How to calculate MAE and RMSE
How to use Python zip and enumerate
[Sakura Rental Server] (For beginners) How to build an environment for Python, pyenv, and Flask. | For csh
How to use is and == in Python
SublimeText2 and SublimeLinter --Syntax check for Python3--
How to set proxy, redirect and SSL authentication for Python Requests module
How to install MeCab (v0.996) and libraries for Python without administrator privileges
Memo # 4 for Python beginners to read "Detailed Python Grammar"
The fastest way for beginners to master Python
[Python] How to use two types of type ()
How to make Spigot plugin (for Java beginners)
How to generate permutations in Python and C ++
Causal reasoning and causal search with Python (for beginners)
Memo # 3 for Python beginners to read "Detailed Python Grammar"
[Python] How to read data from CIFAR-10 and CIFAR-100
How to install Python for pharmaceutical company researchers
Memo # 1 for Python beginners to read "Detailed Python Grammar"
How to use data analysis tools for beginners
How to convert SVG to PDF and PNG [Python]
Try to calculate RPN in Python (for beginners)
Easy understanding of Python for & arrays (for super beginners)
Memo # 2 for Python beginners to read "Detailed Python Grammar"
How to get dictionary type elements of Python 2.7
[Python] How to use hash function and tuple.
Memo # 7 for Python beginners to read "Detailed Python Grammar"
Introduction to Programming (Python) TA Tendency for beginners
Memo # 6 for Python beginners to read "Detailed Python Grammar"
How to handle datetime type in python sqlite3
[For beginners] How to study programming Private memo
Memo # 5 for Python beginners to read "Detailed Python Grammar"
How to plot autocorrelation and partial autocorrelation in python
About Python external module import <For super beginners>
How to install Python
How to install python
python textbook for beginners
[Python] How to create a dictionary type list, add / change / delete elements, and extract with a for statement