Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
intresting pattern
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#python 3.5.2 # Python program to print pattern def StarPattern(height): # This loop prints number of rows for i in range(height): # For every row, first '*' will be # printed Height-rowNumber times. for j in range(height-1,i,-1): print("*",end="") # Print character '*' and Row number # alternately boolean variable to # decide wheather to print char or int printChar = False for j in range(((i*2) +1)): if ( printChar ): print("*",end="") else: print(i + 1,end="") # Each time after printing char # or int reverse the boolean variable # to print alternatively printChar = not printChar # After printing char and int, # it will print '*' for j in range(height-1,i,-1): print("*",end="") print() # Driver code height = 21 StarPattern(height)
[
+
]
Show input
Absolute running time: 0.18 sec, cpu time: 0.13 sec, memory peak: 6 Mb, absolute service time: 0,18 sec
edit mode
|
history
|
discussion