当前位置:网站首页>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=' ')
边栏推荐
- Visual design form QT designer design gui single form program
- Line test - graphic reasoning - 2 - black and white lattice class
- What is fake sharing after filling the previous hole?
- Unity local coordinates and world coordinates
- Software evaluation center ▏ what are the basic processes and precautions for automated testing?
- Cataloger integrates lidar and IMU for 2D mapping
- LeetCode707. Design linked list
- 行测-图形推理-3-对称图形类
- 微服务架构开源框架详情介绍
- ADC采样率(HZ)是什么怎么计算
猜你喜欢
0-5VAC转4-20mA交流电流隔离变送器/转换模块
Redis cluster installation
行測-圖形推理-4-字母類
Loki, the "open source star picking program", realizes the efficient management of harbor logs
Early childhood education industry of "screwing bar": trillion market, difficult to be a giant
行测-图形推理-3-对称图形类
Robot autonomous exploration series papers environment code
新版代挂网站PHP源码+去除授权/支持燃鹅代抽
Leetcode1984. Minimum difference in student scores
C # realizes the communication between Modbus protocol and PLC
随机推荐
GBU1510-ASEMI电源专用15A整流桥GBU1510
C # Development -- pit encountered in JS intermodulation
DTC社群运营怎么做?
Microbial Health Network, How to restore Microbial Communities
LeetCode203. Remove linked list elements
行测-图形推理-9-线条问题类
Select sort (illustration +c code)
How to choose the appropriate automated testing tools?
Form组件常用校验规则-2(持续更新中~)
Visual studio 2019 installation
Leetcode19. Delete the penultimate node of the linked list [double pointer]
Microservice Remote debug, nocalhost + rainbond microservice Development second Bomb
PHP records the pitfalls encountered in the complete docking of Tencent cloud live broadcast and im live group chat
Leetcode206. Reverse linked list
Debezium series: binlogreader for source code reading
What does it mean to prefix a string with F?
Revit secondary development - get the project file path
「开源摘星计划」Loki实现Harbor日志的高效管理
Failed to initialize rosdep after installing ROS
筑起云端 “免疫”屏障,让你的数据有备无患