Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the for loop of Python full stack

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to use Python full-stack for loop". In daily operation, I believe many people have doubts about how to use Python full-stack for loop. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "how to use Python full-stack for loop". Next, please follow the editor to study!

1. Two-way cycle exercise # 1. Complete ten rows and ten rows of small stars j = 0 while j in two loops

< 10: # 打印星星 i = 0 while i < 10: print("*",end="") i+=1 # 打印换行 print() j += 1# 2.用两个循环完成十行十列隔列换色的小星星"""☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★"""i = 0while i < 10: # 打印一行黑白相间的星星 j = 0 while j < 10: if j % 2 == 0: print("☆",end="") else: print("★",end="") j +=1 # 打印换行 print() i+=1# 3.用两个循环完成十行十列隔行换色的小星星"""★★★★★★★★★★☆☆☆☆☆☆☆☆☆☆★★★★★★★★★★☆☆☆☆☆☆☆☆☆☆★★★★★★★★★★☆☆☆☆☆☆☆☆☆☆★★★★★★★★★★☆☆☆☆☆☆☆☆☆☆★★★★★★★★★★☆☆☆☆☆☆☆☆☆☆""""""外层的循环i动的慢内层的循环j动的快外层的i动一次, 内层的循环动10次"""i = 0while i < 10 : j = 0 while j < 10: if i % 2 == 0: print("☆",end="") else: print("★",end="") j +=1 print() i +=1# 4.99乘法表# 方向一i = 1while i = 1 : kongge = 9 - i # 打印空格 while kongge >

0: print ("", end= ") kongge-= 1 # print expression j = 1 while j 0: print (", end=") kongge-= 1 # print star xingxing = 2 * I-1 j = 1 while j

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report