1、Python 定义变量、判断函数、循环
# -*- coding: utf-8 -*-
__author__ = 'Admin'
print('hello python')
#定义变量
a =3
b = 4
c =a+b
print(c)
#判断语句
score = 90
if score >= 80 :
print("优秀")
elif score >=60 :
print("及格")
elif score >= 30 :
print("不及格")
else:
print("很差")
#循环
for i in range(1,10):
print("循环练习")
print(i)
#拼接语句
print("Item {0} is ok {1} hello {2}".format(i,i*100 , "ketty"))
2、Python 函数
<pre style="font-family: 宋体; font-size: 12pt; background-color: rgb(255, 255, 255);"><pre name="code" class="python">#-*- coding:utf-8 -*-
__author__ = 'Admin'
#无参函数
def sayhello():
print("hello Python!")
sayhello()
#有参函数
def max(a,b):
if a>b :
return a
else:
return b
print(max(299,899))