Python (Python 3.7.7) installation and basic grammar

I installed python and summarized the basic grammar flat. Make the article understandable just by looking at anyone who has worked on some PG language ** I would like to brush up each time **

Installation

■ Installation package Download the required version (this time select the Windows x86-64 web-based installer for 3.7.7) and install it. ☑ of Install for all users has been removed. When completed, the file will be created below.   C:\Users\XXX\AppData\Local\Programs\Python

プレゼンテーション1.png

Use of IDEL

When the installation is complete, Python will be added to the menu as shown. Untitled.png Typical development support tools include PyCharm, Microsoft Visual Studio, and eclipse (PyDev add-in), but this page uses IDEL, which is the default installed development tool.

無題1.png
  1. Select IDEL and start it. If you don't like the white screen, select Option → config IDLE → Highlights and select IDLE Dark.

  2. Select File → New File to open another window.

  3. Write the command statement in python in a separate window and execute Save (Ctrl + S) → Run Module (F5) to execute the process on the Shell screen.

Basic grammar

I will briefly describe how to use it. Please refer to the comments for explanations. At least this is enough to make it readable.

#The comment is sharp.

#<Part 1: hello world ・ ・ ・ Do not put space before print, double-byte space is also prohibited>
print('hello world')

#<Part 2: Arguments of print function>
print('hello world',10,10.5)         #Output with multiple arguments
print('hello world',10,10.5,sep=':')  #Delimiter

#<Part 3: Variable (type is automatic conversion) and data input (if input, type will be Str even if you enter numbers)>
test = input('Please put something')
print(test)             #Variable output
print((int(test))*1.08) #When calculating, convert str to int and calculate

#<Part 4: How to operate character strings>
test ='SAMPLE'.replace('A','I') #String replacement
print(test)

#<Part 5: Conditional branching>
test = input('Please put in a horse number')
if test.isdigit():  #Judgment of whether it is a numerical value(In the opposite case, if not)
    umaban = int(test)
    if umaban <6 :  #6 or less(Conditional statement nesting)
        print('The inner frame')
    elif umaban <12 :  #If 12 or less
        print('Middle frame')
    else:  #If not less than 12
        print('Outer frame')
else:  #If not a number
    print('Please enter a number')

#<Part 6: Loop for statement>
dayOfWeek =['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
for day in dayOfWeek : #All list of arrays
    print(day)
print('--------------------')
for day in dayOfWeek[1:6] : #List of arrays 2nd to 5th
    print(day)
print('--------------------')
for test2 in range(5) : #Repeat 5 times
    print(test2)
    test2 = test2 + 1
print('--------------------')
for test3 in range(6,11) : #6 repeats up to 10 times
    print(test3,'counter')
    test3 = test3 + 2 #Experiment. test3
    print(test3,'When manually added')
print('--------------------')

#<Part 7: Definition of function>
def method1(): #No arguments
    print('Everyone','Comment 1')
def method2(other): #With arguments
    print(other,'Comment 2')

method1()
method2('Hogehoge')
print('--------------------')

that's all.

Recommended Posts

Python installation and basic grammar
Python (Python 3.7.7) installation and basic grammar
Python3 basic grammar
Java and Python basic grammar comparison
Python basic grammar / algorithm
Python basic grammar (miscellaneous)
Python basic grammar note (4)
Python basic grammar memo
Python Basic Grammar Memo (Part 1)
Python basic grammar (miscellaneous) Memo (2)
I learned Python basic grammar
Source installation and installation of Python
Python basic grammar (miscellaneous) Memo (4)
Python installation
Python installation
Installation of SciPy and matplotlib (Python)
Python Basic Course (14 Modules and Packages)
Basic grammar of Python3 system (dictionary)
Installation of Visual studio code and installation of python
RF Python Basic_01
Python installation and package management with pip
Elasticsearch installation and basic operation for ubuntu
Python installation (Windows)
Basic Python writing
[Basic grammar] Differences between Ruby / Python / PHP
Python basic operation 3rd: Object-oriented and class
Python grammar notes
[Python] I personally summarized the basic grammar.
Basic grammar of Python3 system (character string)
RF Python Basic_02
Differences between Ruby and Python (basic syntax)
Python installation 2020 (macOS)
Python3.4 installation notes
BESS Development Memo # 01: BESS Installation and Basic Usage
Comparing the basic grammar of Python and Go in an easy-to-understand manner
Instant method grammar for Python and Ruby (studying)
Python3 Engineer Certification Basic Exam-Notes and Problem Trends-
Installation of Python3 and Flask [Environment construction summary]
VBA user tried using Python / R: basic grammar
[Python / Chrome] Basic settings and operations for scraping
Comparison of Python and Ruby (Environment / Grammar / Literal)
Basic operation of Python Pandas Series and Dataframe (1)
[Go] Basic grammar ① Definition
[python] Compress and decompress
Python I'm also basic
Python and numpy tips
Python Basic Course (7 Dictionary)
[Python] pip and wheel
python openCV installation (memo)
Reinforcement learning 1 Python installation
Basic sorting in Python
[Go] Basic grammar ② Statement
Python ~ Grammar speed learning ~
Batch design and python
Python iterators and generators
Python basic course (9 iterations)
jupyter and pandas installation
Python installation method Windows
[python] class basic methods
Python packages and modules
Vue-Cli and Python integration