Today, I officially started my period of 8-10 weeks of cognitive training, just today I met a teacher told us to Python. Learning content today can be summarized as follows:
Python basis
1. What is the programming language
Programming language (programming language), is used to define the form of a computer program language. It is a standardized communication skills, to issue instructions to the computer. A computer language allows programmers to accurately define the data required for the computer to use, and precisely define actions in different situations should be taken.
The first programming language is generated after computer invention, it was used to control the Jacquard loom and the automatic player piano action. In the computer field we have invented thousands of different programming languages, and there are still new programming language born each year. Many programming languages require illustrated by way of instruction computing program, and some programming language belongs to declarative programming, indicating the desired results, rather than how to calculate.
It describes the programming languages can generally be divided into syntax and semantics. Syntax is a programming language, letter or symbol combination which is correct, it is programmed, the semantic interpretation. Some languages are defined by the specification document, for example, the C language specification document is part of the ISO standard, version after 2011 as ISO / IEC 9899: 2011, and other languages (like Perl) have a major programming language file , seen as a reference implementation.
Programming languages commonly known as "computer language," very many species, in general can be divided into machine language, assembly language, high-level language three categories. Each computer to do one action, a step already are in accordance with the programmed computer language program execution, a program is a set of computer instructions to be executed, and all the procedures are used at our disposal to write the language. So people want to control computer must be issued through the computer language commands to the computer. Current general-purpose programming language has two forms: assembly language and high-level language.
And today I have contacted Python is a high level language
2. Computer Organization
cpu memory external storage device input output device
3. Installation and Use
3.1. Python interpreter is installed
https://www.python.org
Click Downloads to download
3.2 Download, install pycharm Editor
https://www.jetbrains.com/pycharm/
Click Download to download the software Pycharm
3.3 Activating use
Can be found on CSDN
4 variables
The amount may change
# Variable value 'qing' will produce a memory address in the memory address
# Variable name corresponds to the ID number for the same variable bindings
# = To bind together two
Naming variables
Hump nomenclature
AgeOfQing
# Python can be used
Underline nomenclature
age-of-qing
Variable names do not boil the way
Use Chinese way
The variable name is too long
Variable noun lied
5. Constant
It refers to the same amount
The constant is variable in nature, it will not have any chance in Python restrictions you can not modify variables
Naming conventions
Variable names all uppercase
6. The user interacts with the program
Input:
Python:
input()
Output:
print()
7. Comments
Single-line comments #
Shortcut Ctrl + /
Multi-line comments triple quotes '' ''
# 1 by index value (forward + reverse take take), can only take
# Take forward
str1=‘hello world!’
print(str1[0])
# Reverse take
print(str1[-2])
# 2. Slice (step)
print(str1[0:5])#hello
print (str1 [0: 6: 2]) #hlo
# 3. Length len
print (referred to as (str1))
# 4 members and not in operation in
print(‘h’ in str1)#true
print('h' not in str1:) #false
# 5 Remove the blank strip
print (str.strip ()) # remove left spaces on both sides of the string l
print (str1.strip ( '!')) # specified string is removed
Cycle # 7
# Of str1 string traversal, print each character
for line in str1 :
print(line)
7. Output Formatting
execise1 str=' alex' print(str) str=' alex' print(str.strip()) execise2,3 str=' alex' print(str.startswith('al')) print(str.endswith('X')) #execise4 str=' alex' print(str) str1=str.replace('l','p') print(str1) execise5 str=' alex' print(str.split('l')) execise6,7 str=' alex' print(str.lower()) print(str.upper()) execise8,9,10 str=' alex' print(str[1]) print(str[0:3]) print(str[3:5]) execise11 str=' alex' print(str.find('e')) execise12 str=' alex' print(str[0:4])