Pat B 1006 question Python3 code

Source: Internet
Author: User

Pat B 1006 Python3 Code Catalog
    • Pat B 1006 question Python3 code
        • Directory
        • Code

Topic:
Let us use the letter B to denote "hundred", the letter S for "Ten", "12...N" to represent the single digit n (<10), in a different format to output any of the 3-bit positive integer. For example, 234 should be output as BBSSS1234, because it has 2 "hundred", 3 "ten", and a single digit of 4.

Input format: Each test input contains 1 test cases, giving a positive integer n (<1000).

Output format: One row for each test case output n in the specified format.

Input Sample 1:
234
Output Example 1:
BBSSS1234
Input Sample 2:
23
Output Example 2:
SS123

Code
#-*-Coding:utf-8-*-"" " Created on Mon Mar 22:45:41 2017@author:xyq152438 " "" def Panduan(a):b = Str (a) list_1 = [] list_2 = [] List_3 = [] Baiwei =int (int (a)/ -)#判断百位, 10, gentlemen, 10. You can use A%100/10 .A_1=int (a)-int (baiwei* -) Shiwei = a_1/TenGewei = a_1%Ten    ifLen (b) = =3:#三位数的情况         forIinchRange (int (baiwei)): List_1.append (' B ')#B转为数组str_1 ="'. Join (List_1)#B数组转为字符串        ifint (Shiwei) = =0: str_2 =' 0 '        Else: forIinchRange (int (Shiwei)): List_2.append (' S ') str_2 ="'. Join (List_2)ifint (Gewei) = =0: Print (str_1+str_2+' 0 ')Else: forIinchRange (int (gewei)): List_3.append (str (i+1)) Str_3 ="'. Join (list_3) print (str_1+str_2+str_3)elifLen (b) = =2:#2位数情况         forIinchRange (int (Shiwei)): List_2.append (' S ') str_2 ="'. Join (List_2)ifint (Gewei) = =0: Print (str_2+' 0 ')Else: forIinchRange (int (gewei)): List_3.append (str (i+1)) Str_3 ="'. Join (list_3) print (str_2+str_3)elifLen (b) = =1:#个位数情况        ifint (Gewei) = =0: Print (0)Else: forIinchRange (int (gewei)): List_3.append (str (i+1)) Str_3 ="'. Join (list_3) print (str_3) a = input () Panduan (a)
If you feel that my article is helpful to you, please help click on the ads to support the development of this site, thank you!
This article is published by "Waitig" in the English blog This article fixed link: Pat B 1006 Python3 Code WordPress Technical Exchange Group: 451350210
If you feel that the article is helpful to you, you can sponsor:

Pat B 1006 question Python3 code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.