如何用while循环输出十行十列变色★☆
输出十行十列星星
k = 0 #设置一个终止变量
while k < 10:
i = 0 #设置一个满十换行变量
while i < 10:
print('★',end='')
i += 1 #满十换行
print('\n',end='') #相当于print() \n 和 end=“ 相互抵消
k += 1 #满十终止程序 输出结果
★★★★★★★★★★
★★★★★★★★★★
★★★★★★★★★★
★★★★★★★★★★
★★★★★★★★★★
★★★★★★★★★★
★★★★★★★★★★
★★★★★★★★★★
★★★★★★★★★★
★★★★★★★★★★
输出十行十列隔列变色星星
k = 0
while k < 10:
i = 0
while i < 10 :
if i % 2==1:
print('★',end='')
else:
print('☆',end = '')
i += 1
print()
k += 1 输出结果
☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★
输出十行十列隔行变色星星
k = 0
while k < 10:
if k %2 ==0:
i = 0
while i < 10:
print('★',end = '')
i += 1 elif k %2 ==1:
i = 0
while i < 10:
print('☆',end = '')
i += 1
print()
k += 1 输出结果
★★★★★★★★★★
☆☆☆☆☆☆☆☆☆☆
★★★★★★★★★★
☆☆☆☆☆☆☆☆☆☆
★★★★★★★★★★
☆☆☆☆☆☆☆☆☆☆
★★★★★★★★★★
☆☆☆☆☆☆☆☆☆☆
★★★★★★★★★★
☆☆☆☆☆☆☆☆☆☆
如何用while循环输出十行十列变色★☆的更多相关文章
- 如何用while循环 输出一个九九乘法表
方法一 i = 1 while i < 10: k = 1 while k <= i: print('%d*%d=%2d '% (i,k,i*k),end='') #end='' 表示不换 ...
- For循环输出一个表格
<!-- 作者:郑伟钊 时间:2017-01-16 描述:通过一个循环的嵌套输出一个表格 --> <?php header("Content-type:text/html; ...
- 功能要求:定义一个两行三列的二维数组 names 并赋值,使用二重循环输出二维数组中的元素。
功能要求:定义一个两行三列的二维数组 names 并赋值,使用二重循环输出二维数组中的元素 names={{"tom","jack","mike&qu ...
- 使用for循环输出杨辉三角-还是不懂得需要复习
package com.chongrui.test; /* *使用for循环输出杨辉三角杨辉三角形由数字排列,可以把它看作一个数字表,其基本特征是两侧的数值均为1,其他位置的数值是其正上方的数值与左上 ...
- awk 输出前 N 列的最简单方法
最近遇到一种场景,需要输出一个文本信息的前 N 列. 众所周知 cut 可以指定分隔符并指定列的范围,如 cut -d' ' -f-4 就是以空格为分隔符输出前 4 列.但是 cut 的分隔符只能是一 ...
- 关于hasNextInt判断后无限循环输出else项的解决办法
话不多说,上来就是干! import java.util.Scanner; public class Test_hasNextInt { /** * @param args */ public sta ...
- Thinkphp_View(1)循环输出
循环输出主要是使用volist和foreach标签输出. VOLIST volist标签通常用于查询数据集(select方法)的结果输出,通常模型的select方法返回的结果是一个二维数组,可以直接使 ...
- JavaScript学习笔记-循环输出菱形,并可菱形自定义大小
var Cen = 6;//定义菱形中部为第几行(起始值为0) //for循环输出菱形 document.write("<button onclick='xh()'>点我for循 ...
- [C#]循环输出 000 - 999999
循环输出 000 - 999999 ; i < ; i++) { , i.ToString().Length); j < 7; j++) { Debug.WriteLine(i.ToStr ...
随机推荐
- TensorFlow问题:The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
1. 问题描述 The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available o ...
- Android基础知识06—活动的四大启动模式
------ 活动的启动模式 ------ 在实际项目中应该根据特定的需求为每个活动指定恰当的启动模式. 四种启动模式: standard . singleTop . singleTask . sin ...
- PHP中header的作用
1.跳转: //若等待时间为0,则与header("location:")等效. //Header("Location:http://localhost//sessio ...
- datagrid 列鼠标悬浮显示全部信息
首次发表随笔,且是java新手,求不黑,可能在高手眼里好笑,嘿嘿1,样式设置超过字数限制显示省略号:<style type="text/css"> .datagrid- ...
- RAID 构建
RAID的创建 第一步:先查看我们系统的磁盘情况 [root@station40 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda ...
- 【ASP.NET MVC 学习笔记】- 18 Bundle(捆绑)
本文参考:http://www.cnblogs.com/willick/p/3438272.html 1.捆绑(Bundle),一个在 View 和 Layout 中用于组织优化浏览器请求的 CSS ...
- 网络库Alamofire使用方法学习笔记
Github地址 由于Alamofire是swift网络库,所以,以下的所有介绍均基于swift项目 导入Alamofire 以下为使用cocoapods导入,其余的方式请参考官网 source 'h ...
- C++获取Windows7 32位系统中所有进程名(类似于任务管理器中的进程)
代码是网上查找资料,然后自己调试,修改之后可以运行. 系统:win7 32位,VS2008 ------------------------------------------------------ ...
- Treasure of the Chimp Island
Treasure of the Chimp Island Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- Android 开发笔记___图像视图__简单截屏
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...