使用字母打印 K 的程序
Python 用于在较短时间内轻松打印不同模式,以符合用户需求。同样的,我们可以使用英语字母打印字母 K。
示例
在此示例中,我们将使用 K 字母创建字母 K。以下是代码。
string=""
j = 7
i = 0
for Row in range(0,10):
for Col in range(0,10):
if (Col == 1 or ((Row == Col + 1) and Col != 0)):
string=string+"K"
elif (Row == i and Col == j):
string=string+"K"
i=i+1
j=j-1
else:
string=string+" "
string=string+"\n"
print(string)
输出
K K K K K K KK K K K K K K K K K K K K K
示例
这是使用英语字母打印字母 K 的另一种方法
def print_k():
print("A A")
print("A A ")
print("A A ")
print("AA ")
print("A A ")
print("A A ")
print("A A")
print_k()
输出
A A A A A A AA A A A A A A
示例
在此示例中,我们将创建另一种方法来使用字母打印字母 K。
def display(n):
val = n
while ( val >= 0) :
c = 80
for j in range(val + 1):
print( chr ( c + j ), end = " ")
val = val - 1
print()
for i in range(n + 1):
c = 100
for j in range( i + 1):
print( chr ( c + j), end =" ")
print()
n = 8
display(n)
输出
P Q R S T U V W X P Q R S T U V W P Q R S T U V P Q R S T U P Q R S T P Q R S P Q R P Q P d d e d e f d e f g d e f g h d e f g h i d e f g h i j d e f g h i j k d e f g h i j k l
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP