当前位置:网站首页>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=' ')
边栏推荐
- Debezium系列之:源码阅读之SnapshotReader
- 微服務遠程Debug,Nocalhost + Rainbond微服務開發第二彈
- 一次搞明白 Session、Cookie、Token,面试问题全稿定
- PHP records the pitfalls encountered in the complete docking of Tencent cloud live broadcast and im live group chat
- Debezium series: support the use of variables in the Kill Command
- Common verification rules of form components -2 (continuously updating ~)
- Build an "immune" barrier in the cloud to prepare your data
- 软件测评中心▏自动化测试有哪些基本流程和注意事项?
- Software evaluation center ▏ what are the basic processes and precautions for automated testing?
- What is ADC sampling rate (Hz) and how to calculate it
猜你喜欢
Line measurement - graphic reasoning -9- line problem class
Personal statement of testers from Shuangfei large factory: is education important for testers?
Digital transformation: five steps to promote enterprise progress
Visual studio 2019 installation
面试百问:如何测试App性能?
What does the model number of asemi rectifier bridge kbpc1510 represent
Yarn cannot view the historical task log of yarn after enabling ACL user authentication. Solution
LeetCode203. Remove linked list elements
ASP.NET Core入门五
Line test - graphic reasoning - 3 - symmetric graphic class
随机推荐
数据库每日一题---第22天:最后一次登录
Unity 动态合并网格纹理
Time convolution Network + soft threshold + attention mechanism to realize residual life prediction of mechanical equipment
PCL . VTK files and Mutual conversion of PCD
CTF练习
Take full control! Create a "leading cockpit" for smart city construction
Redis官方ORM框架比RedisTemplate更优雅
Personal statement of testers from Shuangfei large factory: is education important for testers?
DTC社群运营怎么做?
全面掌控!打造智慧城市建设的“领导驾驶舱”
ADC采样率(HZ)是什么怎么计算
GBU1510-ASEMI电源专用15A整流桥GBU1510
今日创见|企业促进创新的5大关键要素
Years of summary, some core suggestions for learning programming
LeetCode144. Preorder traversal of binary tree
Why is network i/o blocked?
「开源摘星计划」Loki实现Harbor日志的高效管理
面试百问:如何测试App性能?
0-5vac to 4-20mA AC current isolated transmitter / conversion module
微服务架构开源框架详情介绍