python基础-1st step for python

本文介绍了Python的基础知识,包括注释方式、算术运算符、类型检查、用户输入、输出格式化、条件语句、循环结构以及导入模块。特别讨论了`print()`函数的使用和`random`模块生成随机数的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


#!/usr/bin/pythonXX

---means which version of python to create a program
# XXXXXXX
---means single notes ,for note
"""
XXXXXXXX
XXXX
XXX
"""
---means numbers notes,for note



arithmetic operator:
+,-
*,/
//,%----means9//2=4,9%2=1
**---means 2**3=8


type(X)   
---show the type of parement X
raw_input() 
input()
---intput one number or string from keboard
print("%s"%XX)
---instead of XX


if sentence :
    print
elif sentence :
    print
else :
    print
while:
i=1
while i<10 :
    q=1
    while q<i :
        print("%d * %d = %d"%(i,q,i*q),end="/t")
        q +=1
    i+=1
for:
for i in list :
    print(i)

for i in range(1,20):
    print(i)
if the for end with nothing(not the break) ,there is else-function start
for i in list :
    print
    if :
    break 
else :
    print

import random
a = random.randint(X,XX)

from __future__ import print_function
print('123123', end='')
python version 2.7 need import ;need not to get a new line ,and means the line end with the parameter of "end"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值