Python Pattern Programs - Printing Stars in Z Shape

preview_player
Показать описание
In this Python Pattern Printing Programs video tutorial you will learn to print star '*' in Z shape in detail.

If you are using Python 2 then if you write this code you will get error because in python 2 print is not a function and also we cant use end there so you need to use print as statement and instead of end you need to use coma (,) at the end of print statement to get the same output.

in python 3 you write print like this:
print("*',end="")

in python 2 you need to write:
print "*",

For more free tutorials on computer programming
Рекомендации по теме
Комментарии
Автор

Can't thank you enough for such easy to learn tutorials, there are some basics that some teachers choose skip assuming that the students would know of them but because of those missing minor details there was a huge gap in my logics which was perfectly filled by your tutorials. Thanks again!!👍

sajalkumar
Автор

for row in range(6):
for col in range(6):
if row==0 or row==5 or (row==5-col):
print("*", end=" ")
else:
print(end=" ")
print()

dstgiod
Автор

thanks a lot amul, cause of you now I can print a-z pattern.

surajtaru
Автор

Thank you mam.. Very helpful and always greatfull😊

pannagabm
Автор

Thank you so much Amulya Ji! really this course helped me to gain confidence and move further

chethangopal
Автор

num_stars = 6
for i in range(num_stars):
if(i==0 or i == num_stars-1):
print("*" * num_stars)
else:
print(" "*(num_stars-(2+i)) + "*" + " "*(i+1))

sanjibkumarjena
Автор

n=int(input ("enter no of rows "))
For i in range (0, n):
For j in range (0, n):
If row==O or row == n-1 or row + col ==n-1 :

Print ("*", end="")
Else:
Print (end =" ")


Is it crct mam ?

tejasreem
Автор

Thank u very much for your ideas. I really like your way of presentation. All the best and and keep give ore sample then and there. Thanks and regards, M. Raju

rajuindia
Автор

for row in range(6):
for col in range(6):
if ((row==0 or row==5)) or ((col+row==5 and 0<row<5)):
print('*', end='')
else:
print(end=' ')
print()
For Z no need any extra variable please try. Please try this one and say if it is in right manner or not.

hardikambaliya
Автор

This video is great and really helpful.
Can I know the code for Z pattern using a single loop.

reddaboinavasista
Автор

How about this?
for row in range (0, n):
for col in range (0, n):
if (row==0) or (row==n-1) or (row+col==n):
Print("*", end=" ")
else:
print(" ")

harikrishna
Автор

Ma'am i need ur help plzz help me!!

Artistry-
Автор

Aree, If Statement True Hue ... First n last row * sey bhar jaayngi ... But bich wale ka kya .. if true hui, to elif exicute hi nahi Hoti toh bich ke part ka kya

harshvardhan
Автор

Mera output galat aa rha hai....want to do ...pls help

shrutism
Автор

mam please javascript kaisha hoga karke dona A type print please sir, mam

shivshankarguptashiv