VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > python入门 >
  • python入门教程之Python基础语法精华

本站最新发布   Python从入门到精通|Python基础教程
试听地址  
https://www.xin3721.com/eschool/pythonxin3721/


  • Data types
    • Numbers
    • Strings
    • Printing
    • Lists
    • Dictionaries
    • Booleans
    • Tuples
    • Sets
  • Comparison Operators
  • if, elif, else Statements
  • for Loops
  • while Loops
  • range()
  • list comprehension
  • functions
  • lambda expressions
  • map and filter
  • methods

 

Data types

Numbers

In [1]:
1 + 1 + 5
Out[1]:
7
 

1 * 3

In [2]:
1 / 2
Out[2]:
0.5
In [3]:
2 ** 4
Out[3]:
16
In [4]:
4 % 2
Out[4]:
0
In [5]:
5 % 2
Out[5]:
1
In [6]:
(2 + 3) * (5 + 5)
Out[6]:
50
In [7]:
x = 2
y = 3
In [8]:
z = x + y
In [9]:
z
Out[9]:
5
 

Strings

In [10]:
'single quotes'
Out[10]:
'single quotes'
In [11]:
"double quotes"
Out[11]:
'double quotes'
In [12]:
" wrap lot's of other quotes"
Out[12]:
" wrap lot's of other quotes"
In [13]:
# Can not start with number or special characters
name_of_var = 2
 

Printing

In [14]:
x = 'hello'
In [15]:
x
Out[15]:
'hello'
 

Variable Assignment

In [ ]:
 
In [ ]:
 
In [ ]:
 
In [22]:
print(x)
 
hello
In [23]:
num = 12
name = 'Sam'
In [24]:
print('My number is: {one}, and my name is: {two}'.format(one=num,two=name))
 
My number is: 12, and my name is: Sam
In [ ]:
 
In [25]:
print('My number is: {}, and my name is: {}'.format(num,name))
 
My number is: 12, and my name is: Sam
 

Lists

In [26]:
[1,2,3]
Out[26]:
[1, 2, 3]
In [27]:
['hi',1,[1,2]]
Out[27]:
['hi', 1, [1, 2]]
In [28]:
my_list = ['a','b','c']
In [29]:
相关教程