首页    新闻    小组    威客    人才    下载    博客    代码贴    在线编程    论坛
代码贴随便看看Python
# 【程序1】
# 题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
# 程序分析:python不用c语言那么麻烦,可以直接用内置的库函数得到结果

from itertools import permutations

perms = permutations([1,2,3,4], 3)

for perm in perms:
    print(perm)
阅读全部 | 小呆阳 贴于 2022年3月28日 17:40     hide bbsi
import turtle

t=turtle.Turtle()

t.penup()

t.goto(0,-50)

t.pendown()

t.begin_fill()

......................
阅读全部 | xiaoyv2673 贴于 2022年3月23日 23:36     hide bbsi
import os
import random
print("""       +++++++++++++++++游戏规则++++++++++++++++++++
        ++++++++++++++++++猜1到10之间的数字++++++++++++
        ++++++++++++++++注意:每次数字是随机的+++++++++""")                                                   
while True:
    want = int(input('请输入你设定猜错失败次数的上线:'))
    if want >10 or want<0:
        print('你输入的不合理!')
        continue
    elif want !=23456789023456543:
        if 5 > want and want > 2:
......................
阅读全部 | 小呆阳 贴于 2022年3月7日 17:50     hide bbsi
height = input("你的身高是(m):")
print(height)
weight = input("你的体重是(kg):")
print(weight)
BMI=float(weight)/float(height)**2
print(f"你的BMI指数为:{BMI}")

if BMI<18.5:
    print("你太瘦啦,美食可以放肆吃起来,哈哈哈哈~~~~")
    
elif BMI<24:
    print("哇哦!你的状态非常健康哦,继续保持健康的生活习惯吧!")
......................
阅读全部 | Lisa_lin 贴于 2022年2月21日 09:24     hide bbsi
import RPi.CPIO as GPIO
from time import sleep

in1 = 24
in2 = 23

en = 25  # 定义输出引脚
temp1 = 1

GPIO.setmode(GPIO.BCM)  # 定义树莓派gpio引脚以BCM方式编号
GPIO.setup(in1, GPIO.OUT)
GPIO.setup(in2, GPIO.OUT)
......................
阅读全部 | 斯玥 贴于 2022年2月16日 18:25     hide bbsi
# -*- coding: UTF-8 -*- 
import pymysql

def readSQL():
    #查询 SQL 语句
    sql = "SELECT id,'apiname',apiurl from apitest_apistep where apitest_apistep.Apitest_id = 2"
    #打开 MySQL 数据库链接
    coon = pymysql.connect(user='root', passwd = 'test123456',db = 'autotest', port = 3306, host='127.0.0.1',charset='utf8')
    #获取数据库操作游标
    cursor = coon.cursor()
    #执行 MySQL 查询语句
    aa = cursor.execute(sql)
......................
阅读全部 | shlgj 贴于 2022年1月28日 14:50     hide bbsi
#-*- coding:UTF-8 -*-

def wfile():
    try: 
        filename = "C:\\Users\\zh\\"+"test.html"
    except IOError:
        print("file creat error")
    else:
        fp = open(filename,'wb')
        fp.write('test'.encode('utf-8'))
        fp.close()
        
......................
阅读全部 | shlgj 贴于 2022年1月27日 19:45     hide bbsi
#插入排序 

def insertsort(li):
    for index in range(1,len(li)):
        value = li[index]
        i = index -1
        while(i>=0 and (value < li[i])):
            
            li[i],li[i+1]=value,li[i]
            i = i-1
li=[4,6,7,3,3,9,1]

......................
阅读全部 | w13011201033 贴于 2022年1月1日 16:16     hide bbsi
#插入排序 

def insertsort(li):
    for index in range(1,len(li)):
        value = li[index]
        i = index -1
        while(i>=0 ):
            if value < li[i]:
                li[i],li[i+1]=value,li[i]
                i = i -1
            else:
                break 
......................
阅读全部 | w13011201033 贴于 2022年1月1日 16:14     hide bbsi
a = ['1','2','3']#a赋值为中括号里的集合
b = ['4','5']
print(a[1])#输出a的第二个元素
print(b[-1])#输出b的最后一个元素
print(a[0])#输出a的第一个元素
print(a[1:])##打印第一个元素之后的内容
print(a[:-1])##打印最后一个元素之前的内容
print(a[::-1])##倒序输出
print(a * 3)##输出三遍
print(a+b)#链接a和b
for c in range(0,10):#c在0到10的范围内(包括0不包括10)
    c += 5
......................
阅读全部 | 绘子手 贴于 2021年12月31日 21:27     hide bbsi
上一页 7 8 9 10 11 12 13 14 15 16 下一页