Basics of python: Output

I had some thoughts, so I modified the contents I'm reposting.

Basic

output

print("Hello World")
#The string is""Or''Must be surrounded by

Comment out

#One-line comment

"""
Multiple lines
Comment out
"""

Calculation

Formula code
addition +
subtraction -
multiplication *
division /
Remainder %
Multiply **

variable

n=1
print(n)
#output: 1
print(n+2)
#output: 3

Variable names that can be used

① Half-width alphabet(Uppercase and lowercase)
② Half-width numbers
③ _(underscore)

important point

① No numbers can be used as the first letter
② Function names such as print are not allowed
③ After booking(Code such as for)Impossible
④ Japanese is not preferred

Delete

Deleted due to circumstances after operation

del variable name

Connect with mold

At the time of output int type (number) str type (string) Etc. cannot be mixed and output Separate or convert and output

n =1 

print("this is"+n)
#error
print("this is"+str(n))
#output:This is 1
print(1+n)
#output: 2

When you want to know the type

print(type(variable))
age = 20
print(type(age))
#output: <class 'int'>

Type conversion

code Contents
str() String
int() Integer value
float() Including decimal point

Recommended Posts

Basics of python: Output
Basics of Python ①
Basics of Python scraping basics
# 4 [python] Basics of functions
[Python] Chapter 02-03 Basics of Python programs (input / output)
Python basics ⑤
Python basics
Python basics ④
python: Basics of using scikit-learn ①
Python basics
Python basics
Python basics
Python basics ③
Python basics ②
Python basics ②
Basics of Python × GIS (Part 1)
Paiza Python Primer 5: Basics of Dictionaries
Getting Started with Python Basics of Python
Review of the basics of Python (FizzBuzz)
Basics of Python x GIS (Part 2)
About the basics list of Python basics
Learn the basics of Python ① Beginners
Python basics: list
Introduction of Python
python learning output
#Python basics (#matplotlib)
Python CGI basics
Python basics: dictionary
Python slice basics
#Python basics (#Numpy 1/2)
Copy of python
#Python basics (#Numpy 2/2)
#Python basics (functions)
Python array basics
Python profiling basics
Python #Numpy basics
Python basics: functions
#Python basics (class)
Python basics summary
Introduction of Python
Basics of binarized image processing with Python
Python: Basics of image recognition using CNN
[Learning memo] Basics of class by python
[Python3] Understand the basics of Beautiful Soup
I didn't know the basics of Python
The basics of running NoxPlayer in Python
[Basics of python basics] Why do __name__ == "__main__"
UnicodeEncodeError struggle with standard output of python3
[Python] Chapter 02-04 Basics of Python Program (About Comments)
[Introduction to Data Scientists] Basics of Python ♬
[Python3] Understand the basics of file operations
[Python] Operation of enumerate
List of python modules
Output the number of CPU cores in Python
Python basics ② for statement
Unification of Python environment
Copy of python preferences
Python basics 8 numpy test
[python] behavior of argmax
[Python of Hikari-] Chapter 05-06 Control Syntax (Basics of Comprehension)
Usage of Python locals ()