Python Study Notes-Day1-Python basics, python-day1-python
1. Translation of advanced languages into machine languages: Interpretation and compilation
Python is an interpreted language.
1.1 syntax common three error types
Syntax error (syntax errors)
Running error (runtime errors)
Semantic Error (semantic errors)
1.3 variables and types
Variable:As the name implies, a variable is a variable value that can be called repeatedly. Improve development efficiency
Variable type (call range ):Global and local variables
Common types of variable values:INTEGER (int), float, str, null)
The variable is relative to the constant: the variable is a fixed amount, such as the circumference rate pi.
1.4 rules defined by variables:
-The variable name can only be any combination of letters, numbers, or underscores.
-The first character of the variable name cannot be a number.
-The following keywords cannot be declared as variable names.
['And', 'as', 'assert ', 'Break', 'class', 'contine', 'def', 'del ', 'elif ', 'else', 'Got t', 'exec ', 'Finally', 'for ', 'from', 'global', 'if', 'import', 'in ', 'Is ', 'lambda', 'not ',' or ', 'pass', 'print', 'raise ', 'Return', 'try', 'while ', 'with', 'yield ']
Python2.X and python3.X output comparison
Python2.x output Syntax: print "output content"
Python3.x output Syntax: print ("output content ")
Input comparison between python2.X and python3.X
python2:name = raw_input("What is your name?") #only on python 2.x
python3:name
=
input
(
"What is your name?"
)
A variable can only start with an underscore or a letter and cannot contain spaces. It cannot contain special numbers,
Variable = variable value (string, integer, floating point, null)
Variable = variable value (= Arithmetic Operator, equal)
Correct: the following code should be displayed to the python Interpreter:
#! /Usr/bin/env python
# Specified Character Set
#-*-Coding: UTF-8 -*-
Python annotation syntax
Single Row gaze: # commented content
Multi-line comment: '''commented content '''
Multi-line comment: "commented content """