当前位置:网站首页>One question per day - pat grade B 1002 questions
One question per day - pat grade B 1002 questions
2022-07-07 23:00:00 【InfoQ】
One 、PAT (Basic Level) Practice ( chinese ) The first 1002 topic
Input format :
Output format :
sample input :
1234567890987654321123456789
sample output :
yi san wu
transform={'1':'yi','2':'er','3':'san','4':'si','5':'wu','6':'liu','7':'qi','8':'ba','9':'jiu','0':'ling'}
# Input
a=input()
# Convert the input numeric string to the form of a list
b=list(a)
# Sum every digit in the number
c=sum(int(i) for i in b)
# The sum result is converted to string form , Used to calculate the length
d=str(c)
# Marker bit , Used to determine for The last of the loop
flag=0
for j in d:
flag=flag+1
# If for The last bit of the loop , Then no spaces are output
if flag==len(d):
#print default end by end='\n', First modify it according to the situation
print(transform[j],end='')
else:
print(transform[j],end=' ')
transform={'1':'yi','2':'er','3':'san','4':'si','5':'wu','6':'liu','7':'qi','8':'ba','9':'jiu','0':'ling'}
a=input()
print("input The type of input :",type(a))
b=list(a)
print(" Forward a list of b by :",b)
#c=sum(int(i) for i in b)
sum=0
for i in a:
s=int(i)
sum=sum+s
print('sum Data type of :',type(sum)," result : ",sum)
d=str(sum)
print(" Convert to string form sum"," type :",type(d)," Number in string form :",d," His length :",len(d))
flag=0
for j in d:
flag=flag+1
if flag==len(d):
print(transform[j],end='')
else:
print(transform[j],end=' ')
边栏推荐
- 0-5vac to 4-20mA AC current isolated transmitter / conversion module
- 一次搞明白 Session、Cookie、Token,面试问题全稿定
- Software evaluation center ▏ what are the basic processes and precautions for automated testing?
- Unity FAQ (I) lack of references
- Years of summary, some core suggestions for learning programming
- 微服務遠程Debug,Nocalhost + Rainbond微服務開發第二彈
- 行测-图形推理-6-相似图形类
- 0-5VAC转4-20mA交流电流隔离变送器/转换模块
- 行测-图形推理-1-汉字类
- Common verification rules of form components -2 (continuously updating ~)
猜你喜欢
Line test graph reasoning graph group class
ASEMI整流桥KBPC1510的型号数字代表什么
Robot autonomous exploration series papers environment code
How to choose the appropriate automated testing tools?
Sword finger offer 55 - I. depth of binary tree
What does the model number of asemi rectifier bridge kbpc1510 represent
It's no exaggeration to say that this is the most user-friendly basic tutorial of pytest I've ever seen
Microbial health network, how to restore microbial communities
Redis official ORM framework is more elegant than redistemplate
The author of LinkedList said he didn't use LinkedList himself
随机推荐
php 记录完整对接腾讯云直播以及im直播群聊 所遇到的坑
知识点滴 - PCB制造工艺流程
Cataloger integrates lidar and IMU for 2D mapping
Debezium系列之:mysql墓碑事件
消费品企业敏捷创新转型案例
Leetcode1984. Minimum difference in student scores
Force deduction - question 561 - array splitting I - step by step parsing
Unity 动态合并网格纹理
Line measurement - graphic reasoning -9- line problem class
IP network active evaluation system -- x-vision
行测-图形推理-1-汉字类
微服務遠程Debug,Nocalhost + Rainbond微服務開發第二彈
Redis官方ORM框架比RedisTemplate更优雅
“拧巴”的早教行业:万亿市场,难出巨头
Build an "immune" barrier in the cloud to prepare your data
Pyqt GUI interface and logic separation
Unity与WebGL的相爱相杀
How to judge whether the input content is "number"
行测-图形推理-5-一笔画类
Debezium系列之:源码阅读之SnapshotReader