Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to Print K using Alphabets
Python is used to print different patterns easily within less time as per the user requirement. In the same way, we can print the letter K using the alphabets available in the English language.
Example
In this example we will create the letter K by using the K alphabet. The below is the code.
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)
Output
K K K K K K KK K K K K K K K K K K K K K
Example
This is another way to print the letter K using the alphabets of the English language
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()
Output
A A A A A A AA A A A A A A
Example
In this example, we will create the other way to print the letter K using the alphabets.
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)
Output
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
Advertisements