栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

蓝桥杯-PYTHON

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

蓝桥杯-PYTHON

前缀表达式
list1 = list(input().split())
m = list1[0]
a = list1[1]	
b = int(list1[2])
def jia():
   return a + b
def jian():
   return a - b
def cheng():
   return a * b
def chu():
   return a // b
if a and b <= 10:
    if m == '+':
        print(jia())
    elif m == '-':
        print(jian())
    elif m == '*':
        print(cheng())
    elif m == '/':
        print(chu())
Anagrams问题
s1 = input()
s2 = input()
if len(s1) != len(s2):
   print("N")
   exit()
s1 = set(s1.lower()) #把所有的字符转换为小写
s2 = set(s2.lower()) #set()是一个无序不重复元素集,基本功能包括
测试和消除重复元素

l1 = list(s1) #把这两个串放在一个列表里面
l2 = list(s2)
l = l1 + l2
if len(set(l)) == len(l1+l2)/2:
    print('Y')
else:
    print('N')
字母图形
while True:
try:
    en = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    n,m = map(int,input().split(" "))
    for i in range(0,n):
            if i == 0:
                print(en[0:m])
            else:
                s = en[i:0:-1] + en
                print(s[0:m])
except:
    break
区间K大数查询
n = input()
s = list(map(int,input().split())) #放在列表里
m = int(input())
for i in range(0,m):
    l,r,K = map(int,input().split())
    list = s[l-1:r]
    list.sort(reverse=True)
    print(list[K-1])
圆的面积
import math #引入π
r = int(input())
s = math.pi * r * r
print("{:.7f}".format(s))#保留小数
寻找数组中的最大值
a = int(input())
array = list(map(int,input().split())) #放在列表里
print(max(array),array.index(max(array)))
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/755679.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号