python的基础试题
2023-09-14 09:12:45 时间
试题1:请使用 Python 中的循环打印输出从1到100的所有奇数。
试题2:请将字符串“你好SsS我正在学 Python@#@#现在需要&*&*&修改字串”中的符号变成一个空格,需要输出的格式为:“你好 我正在学 Python 现在需要 修改字符串”。
试题3:输出9×9乘法口诀表。
试题4:请写出一个函数,当输入函数变量月利润为 I 时,能返回应发放奖金
的总数。例如,输出“利润为100000元时,应发放奖金总数为10000元”。其中,企业发放的奖金根据利润提成。利润( I )低于或等于10力元时,奖金可提10%:利润高于10万元,低于20万元时,低10力元的部分按10%提成,高于10万元的部分,可提成7.5%:利润在20万元到40力元之间时,高于20万元的部分可提成5%;利润在40万元到60万元之间时,高于40万元的部分可提成3%;利润在60力元到100力元之间时,高于60万元的部分可提成
1.5%:利润高于100万元时,超过100力元的部分按1%提成。试题5:用字典的值对字興进行排序,将{1:2,3:4,4:3,2:1,0:0}按照字典的值
从大到小进行排序。
试题1:
for i in range(100):
if i%2 not in [0]:
print(i) #方法很多
试题2:
s = input()
str = s.replace('SsS',' ').replace('&*&*&',' ').replace('@#@#',' ')
print(str)
import re
s = input()
str1 = re.sub('[@#Ss&&*%]+',' ',s)
print(str1)
试题3:
for i in range(1,10):
for j in range(1,10):
if i>=j:
print('{0:.0f}*{1:.0f}={2:.0f}\t'.format(j,i,i*j),end=" ")
#print("%d*%d=%d\t"%(j,i,i*j),end=" ")
print(" ")
试题4:
def profit(I):
c=10000
I /= c;
if I<=10:
return I*0.1*c
elif I>10 and I<=20:
return (1+(I-10)*0.075)*c
elif I>20 and I<=40:
return (1.75+(I-20)*0.05)*c
elif I>40 and I<=60:
return (2.75+(I-40)*0.03)*c
elif I>60 and I<=100:
return (3.35+(I-60)*0.015)*c
else:
return (3.95+(I-100)*0.01)*c
I=int(input())
pro = profit(I)
print("利润为%d元,奖金总数为%d元" %(I,pro))
试题5:
import operator
x={1:2,3:4,4:3,0:0}
sorted_x=sorted(x.items(),key=operator.itemgetter(1))
print(sorted_x)
#operator.itemgetter(1)获取对象的第一个域的值
相关文章
- 【Python成长之路】python 基础篇 -- global/nonlocal关键字使用
- python开发基础-Pycharm快捷键
- Python基础(5)--字典
- VS2013中Python学习笔记[基础入门]
- python基础-判断一年中的第几天
- Python - 属性简介"__name__"
- 小白学 Python 爬虫(38):爬虫框架 Scrapy 入门基础(六) Item Pipeline
- Python Django 一对一多表查询关联表字段
- Atitit nlp自然语言处理类库(java python nodejs c#net) 目录 1.1. Python snownlp1 1.2. NLP.js一个nodejs/javascri
- 【Python基础】python爬虫之异步网络爬虫ǃ
- Python入门——针对零基础学习者的资料推荐
- Python每日一练——第16天:字符串分析
- 已解决2. Set PROTOCOL_BUPFERS_PYTHON_iMPLEMENTATION=python (but this will use pure-Python parsing and w
- 【Python金融量化】零基础如何开始学?
- 〖Python零基础入门篇④〗- Pycharm插件安装与常用的插件
- 〖Python零基础入门篇(61)〗- Python 中的迭代器
- Python爬虫基础讲解之请求与响应~
- 【Python成长之路】python 基础篇 -- global/nonlocal关键字使用
- 【Python成长之路】python 基础篇 -- global/nonlocal关键字使用
- 【Python成长之路】python 基础篇 -- 装饰器【华为云分享】
- 6 个必知必会高效 Python 编程技巧
- 构建 Python C 扩展模块
- Python 基础语法
- python基础===jieba模块,Python 中文分词组件
- python基础===Python 代码优化常见技巧
- python基础===八大排序算法的 Python 实现
- 零基础学python拼命学最快要多久?
- 27岁本科毕业,零基础转行Python工程师,其中艰辛只有自己知道
- Python基础(一)
- Python基础数据之列表