当前位置:网站首页>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=' ')
边栏推荐
- This time, let's clear up: synchronous, asynchronous, blocking, non blocking
- 微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
- Matplotlib quick start
- Debezium series: support the use of variables in the Kill Command
- Select sort (illustration +c code)
- Debezium series: introducing support for the final operator
- Take full control! Create a "leading cockpit" for smart city construction
- Ni9185 and ni9234 hardware settings in Ni Max
- 行测-图形推理-3-对称图形类
- Qt Graphicsview图形视图使用总结附流程图开发案例雏形
猜你喜欢
Basic knowledge of linked list
Apple further entered the financial sector through the 'virtual card' security function in IOS 16
PCL .vtk文件与.pcd的相互转换
Robot autonomous exploration DSVP: code parsing
[problem] pytorch installation
Gazebo import the mapping model created by blender
Redis cluster installation
面试百问:如何测试App性能?
肠道里的微生物和皮肤上的一样吗?
Interview questions: how to test app performance?
随机推荐
What does it mean to prefix a string with F?
肠道里的微生物和皮肤上的一样吗?
7-18 simple simulation of banking business queue
What does the model number of asemi rectifier bridge kbpc1510 represent
Debezium系列之:支持 mysql8 的 set role 語句
行测-图形推理-3-对称图形类
PHP method of obtaining image information
ADC采样率(HZ)是什么怎么计算
“拧巴”的早教行业:万亿市场,难出巨头
Online interview, how to better express yourself? In this way, the passing rate will be increased by 50%~
Cataloger integrates lidar and IMU for 2D mapping
Explain in detail the communication mode between arm A7 and risc-v e907 on Quanzhi v853
Line test - graphic reasoning - 3 - symmetric graphic class
LeetCode206. Reverse linked list [double pointer and recursion]
Debezium series: set role statement supporting mysql8
UWA Q & a collection
Some parameters of Haikang IPC
Leetcode206. Reverse linked list
0-5VAC转4-20mA交流电流隔离变送器/转换模块
Redis cluster installation