当前位置:网站首页>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=' ')
边栏推荐
- How pyGame rotates pictures
- This time, let's clear up: synchronous, asynchronous, blocking, non blocking
- Leetcode19. Delete the penultimate node of the linked list [double pointer]
- 消费品企业敏捷创新转型案例
- Revit secondary development - intercept project error / warning pop-up
- It's no exaggeration to say that this is the most user-friendly basic tutorial of pytest I've ever seen
- 行測-圖形推理-4-字母類
- Debezium系列之:支持 mysql8 的 set role 語句
- What does it mean to prefix a string with F?
- [environment] pycharm sets the tool to convert QRC into py file
猜你喜欢

今日创见|企业促进创新的5大关键要素

微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹

ASEMI整流桥KBPC1510的型号数字代表什么

数字化转型:五个步骤推动企业进步

DTC社群运营怎么做?

Basic knowledge of binary tree

Yarn cannot view the historical task log of yarn after enabling ACL user authentication. Solution

Robot autonomous exploration series papers environment code

新版代挂网站PHP源码+去除授权/支持燃鹅代抽

CTF exercise
随机推荐
How pyGame rotates pictures
Ligne - raisonnement graphique - 4 - classe de lettres
Sword finger offer 55 - I. depth of binary tree
Redis official ORM framework is more elegant than redistemplate
消息队列与快递柜之间妙不可言的关系
“拧巴”的早教行业:万亿市场,难出巨头
Debezium系列之:支持 mysql8 的 set role 语句
Personal statement of testers from Shuangfei large factory: is education important for testers?
行测-图形推理-6-相似图形类
7-51 combination of two ordered linked list sequences
ADC采样率(HZ)是什么怎么计算
How to choose the appropriate automated testing tools?
Basic knowledge of linked list
What is fake sharing after filling the previous hole?
ASEMI整流桥KBPC1510的型号数字代表什么
Knowledge drop - PCB manufacturing process flow
[environment] pycharm sets the tool to convert QRC into py file
C development -- WPF simple animation
QT graphicsview graphical view usage summary with flow chart development case prototype
Microservice Remote debug, nocalhost + rainbond microservice Development second Bomb