Python Entry 1-1, python1-1
The first python program, the omnipotent 'Hello world'
Python usage, print hello world:
1 # print ('hello world')hello
Hello variable
What is a variable?
Variables are the amount of changes. The core is the word 'change' and 'quantity'. changes are both changing, and the amount is a measure of the state.
How to define variables? Variable name (equivalent to the house number, pointing to the space), equal sign, variable value
name='Egon' sex='male' age=18 level=10
Definition specification of variables:
1. Variable names can only be any combination of letters, numbers, and underscores
2. the first character of the variable name cannot be a number.
3. Keywords cannot be declared as variable names
User-program interaction
File Header
#!/usr/bin/env python# -*- coding: utf-8 -*-
Note
Code comments are divided into single-line and multi-line comments.#
. You can use three pairs of double quotation marks for multi-line comments.""" """
Input
Input: All input values are saved as strings.
Basic Data Type
Number
Int INTEGER: used for identification: age, ID card number, QQ number, and other integer types
Float floating point: used for identification: decimal type, such as salary, height, and weight
String str string:
Used for identification: descriptive content, such as name, gender, nationality, and race
List
userdata = ['name','passwd']
Used for identification: stores multiple values. For example, a person has multiple hobbies.