統計字串以及列印乘法口訣表
1、統計字串中有多少個數字、字母、空格以及其他字元
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2018/1/24 21:29
# @Author : zhouyuyao
# @File : countnums.py
# PyCharm 2017.3.2 (Community Edition)
# Build #PC-173.4127.16, built on December 19, 2017
# JRE: 1.8.0_152-release-1024-b8 amd64
# JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
# Windows 10 10.0
# Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36)
# [MSC v.1900 64 bit (AMD64)] on win32
status=1
while status:
strings = input("Please input a string(`quit` will exit):")
if strings == "quit":
exit(1)
digit = pha = space = other = 0
for i in strings:
if i.isdigit():
digit +=1
elif i.isalpha():
pha +=1
elif i.isspace():
space +=1
else:
other +=1
print("該字串中數字有{0}個,字母有{1}個,空格有{2}個,其他{3}個。".format(digit,pha,space,other))
2、列印乘法口訣表
for i in range(1,10):
for j in range(1,i+1):
print("{0} x {1} = {2}".format(j,i,i*j),end="")
if i ==j:
print("")
1 x 1 = 1
1 x 2 = 22 x 2 = 4
1 x 3 = 32 x 3 = 63 x 3 = 9
1 x 4 = 42 x 4 = 83 x 4 = 124 x 4 = 16
1 x 5 = 52 x 5 = 103 x 5 = 154 x 5 = 205 x 5 = 25
1 x 6 = 62 x 6 = 123 x 6 = 184 x 6 = 245 x 6 = 306 x 6 = 36
1 x 7 = 72 x 7 = 143 x 7 = 214 x 7 = 285 x 7 = 356 x 7 = 427 x 7 = 49
1 x 8 = 82 x 8 = 163 x 8 = 244 x 8 = 325 x 8 = 406 x 8 = 487 x 8 = 568 x 8 = 64
1 x 9 = 92 x 9 = 183 x 9 = 274 x 9 = 365 x 9 = 456 x 9 = 547 x 9 = 638 x 9 = 729 x 9 = 81
相關文章
- java列印乘法口訣Java
- python列印乘法口訣Python
- 乘法口訣表
- JavaScript乘法口訣表JavaScript
- 利用python列印實現九九乘法口訣表Python
- C#版--9*9乘法口訣表C#
- Scala實現乘法口訣
- 如何用python語言發出乘法口訣表Python
- 用js實現一個九九乘法口訣表JS
- L1-080 乘法口訣數列
- 列印99乘法表
- Python列印乘法表Python
- L1-080 乘法口訣數列 分數 20
- c#列印99乘法表C#
- 列印九九乘法表
- PHP列印9*9的乘法表PHP
- C++第四次作業-1000以內偶數和和乘法口訣表C++
- js列印九九乘法表(迴圈)JS
- 用js實現列印九九乘法表JS
- 追姑娘的口訣
- Python 6種列印99乘法表的方法詳解!Python
- 0504圖推十五字口訣
- JAVA基礎--迴圈語句_列印九九乘法表Java
- oracle外部表建立以及收集統計資訊以及臨時表Oracle
- CSS3 Flexbox 口訣CSSS3Flex
- 學習英語中的口訣
- SQL乘法表SQL
- 吉特倉儲管系統(開源WMS)--Web線上報表以及列印模板分享Web
- 怎樣用程式碼寫出99成法口訣!
- 字串統計字串
- 重複列印字串字串
- 統計一個字串中的單詞的個數,並列印各個單詞字串
- js梯形乘法運算表效果JS
- 送你4句口訣 雲端儲存選型不再犯難
- 字串-字元統計2字串字元
- 字串-字元統計1字串字元
- 用SQL實現99乘法表SQL
- 給定一個字串,按Z字形列印,在從左向右,從上往下列印字串字串