程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[Python training camp] Python daily practice -- day 25: Zero product

編輯:Python


Hello, Hello, my name is Dream ah , An interesting Python Blogger , Please go easy on me
2021 Blog star of the year TOP100,2021 Blog star of the year TOP5,Python Quality creators in the field , Welcome to cooperate with me ( At the end of the article VX Want to join the learning exchange group or Learning materials welcome +++)
Introductory notes : This paradise never lacks genius , Hard work is your final ticket !
Last , May we all shine where we can't see , Let's make progress together
“ Ten thousand times sad , There will still be Dream, I've been waiting for you in the warmest place ”, It's me ! Ha ha ha ~

Preface :【Python Training camp 】 Is aimed at Python A war created by language learning Brush questions and revel party! If you don't grasp the solid foundation of knowledge , Welcome to this course :Python Public class It's best to use it together ~ If you like, hurry up and subscribe ! If you don't have self-control or motivation to learn and communicate together , Welcome to send a private letter or add my... At the end of the text VX, I will pull you into the learning exchange group , Let's exchange and study together , Group punch in

Python Practice every day :

  • Title Description
  • Their thinking
  • The source code to share
  • Learning summary
  • The articles ---- Good article recommends

Title Description

Title Description
This question is to fill in the blanks , Just calculate the result , Use the output statement in the code to output the filled results .
As follows 1010 Row data , Each row has 1010 It's an integer , Please find out how many zeros there are at the end of their product ?

5650 4542 3554 473 946 4114 3871 9073 90 4329
2758 7949 6113 5659 5245 7432 3051 4434 6704 3594
9937 1173 6866 3397 4759 7557 3070 2287 1453 9899
1486 5722 3135 1170 4014 5510 5120 729 2880 9019
2049 698 4582 4346 4427 646 9742 7340 1230 7683
5693 7015 6887 7381 4172 4341 2909 2027 7355 5649
6701 6645 1671 5978 2704 9926 295 3125 3878 6785
2066 4247 4800 1578 6652 4616 1113 6205 3264 2915
3966 5291 2904 1285 2193 1428 2265 8730 9436 7074
689 5510 8243 6114 337 4096 8199 7313 3685 211

Their thinking

  • First, the data mentioned in the title , Use the method to represent it in the list we created , In the form of an integer , It is convenient for future calculation and analysis ;list(map(int,''' data '''.split()))
  • Traverse the list in turn and calculate the result of its product ;
  • Then we need to find the end of the result 0 The number of , We need to traverse every number of this result backwards , At this time, we need to change the result into the form of string :a = str(a), In the form of string, we can find its length , And it can be traversed ;
  • When traversing backwards : If appear 0 be +1, Once no zero appears , Exit loop , Get the end 0 The number of .

The source code to share

# Time : 2022/2/20 11:32
# File : Product tail zero .py
# Author : yes Dream ah !
# VX : Xu18300396393
# Ten thousand times sad , There will still be Dream, I've been waiting for you in the warmest place !
import os
import sys
# Please enter your code here 
a = 1
list1 = list(map(int,''' 5650 4542 3554 473 946 4114 3871 9073 90 4329 2758 7949 6113 5659 5245 7432 3051 4434 6704 3594 9937 1173 6866 3397 4759 7557 3070 2287 1453 9899 1486 5722 3135 1170 4014 5510 5120 729 2880 9019 2049 698 4582 4346 4427 646 9742 7340 1230 7683 5693 7015 6887 7381 4172 4341 2909 2027 7355 5649 6701 6645 1671 5978 2704 9926 295 3125 3878 6785 2066 4247 4800 1578 6652 4616 1113 6205 3264 2915 3966 5291 2904 1285 2193 1428 2265 8730 9436 7074 689 5510 8243 6114 337 4096 8199 7313 3685 211 '''.split()))
# print(list1)
for i in list1:
a *= i
# print(a)
a = str(a)
num = 0
for i in range(len(a)-1,0,-1):
if a[i] == '0':
num += 1
else:
break
print(num)

Learning summary

1. Transfer multiple data , In the form of a list , Format :list(map(int,''' data '''.split()))
2. Traversal in reverse order :for i in range(len(a)-1,0,-1)

Today is my day Python The first of the training camp 25 God , I hope to see the best of you every day

The articles ---- Good article recommends

[Python Public class ] Zero base play Python The basic chapter ---- Section 1 :Python The introduction of

[Python Public class ] Zero base play Python Advanced ---- Section 1 :Python File operations in

Come on, let's have a problem swiping Carnival party Well !----【Python Training camp 】
All right. , That's all I want to share with you today
️️️ If you like , Don't be stingy with your one key triple connection ~


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved