統計字串以及列印乘法口訣表
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
相關文章
- python列印乘法口訣Python
- 乘法口訣表
- 利用python列印實現九九乘法口訣表Python
- JavaScript乘法口訣表JavaScript
- 輸出乘法口訣表
- n*n的乘法口訣表
- PAT - 7-20 列印九九口訣表
- 如何用python語言發出乘法口訣表Python
- 用js實現一個九九乘法口訣表JS
- L1-080 乘法口訣數列
- Python列印乘法表Python
- 列印99乘法表
- L1-080 乘法口訣數列 分數 20
- c#列印99乘法表C#
- 列印九九乘法表
- PHP列印9*9的乘法表PHP
- 列印一個九九乘法表
- js列印九九乘法表(迴圈)JS
- 用js實現列印九九乘法表JS
- 追姑娘的口訣
- Python 6種列印99乘法表的方法詳解!Python
- CSS3 Flexbox 口訣CSSS3Flex
- JAVA基礎--迴圈語句_列印九九乘法表Java
- 0504圖推十五字口訣
- 字串統計字串
- 重複列印字串字串
- 九九乘法表
- 字串-字元統計2字串字元
- 字串-字元統計1字串字元
- 字串統計 hd 2017字串
- 寶鯤財經:交易10條風險控制口訣
- 一分一開快.3【大小】精準計劃,快.3的穩賺口訣
- python 列印 ASCII表PythonASCII
- 常量訣,一個永久記憶普朗克常量與阿佛加德羅常數的口訣
- 怎樣用程式碼寫出99成法口訣!
- 口訣研究|網賭回本只能一點一點來W
- 給定一個字串,按Z字形列印,在從左向右,從上往下列印字串字串
- 統計字串字元個數字串字元