Python学习--基础代码练习

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))

 


 
 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值