Download! Download Point responsive WP Theme for FREE!

python-pattern-programming-part-1

You can find variety of python patterns with programming in Python pattern programming Part 1. While doing python programming there are few things to remember like spaces are very important and need accurate coding otherwise your code will not execute.

Python pattern programming – 1
starpattern01

 

 

 

 

 

Python language

def pattern(n):
    for i in range(0,n):
        for j in range(0,i+1):
            print("*",end="")
        print("\r")

n=5
pattern(n)

C language

#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,j;
    printf("Program to create * pyramid\n");
    for (i=0; i<=5; i++) {
        for (j=0; j<i+1; j++) {
            printf("*");
        }
        printf("\n");
    }
}

 

 

 

Python pattern programming – 2

starpattern02

 

 

 

 

 

 

 

def pattern(n):
    for i in range(0,n):
        for j in range(0,i+1):
            print("*",end="")
        print("\n")

n=5
pattern(n)

Python pattern programming – 3

starpattern03

 

 

 

 

Python language

def pattern(n):
    for i in range(n,0,-1):
        for j in range(0,i):
            print("*",end="")
        print("\r")

n=5
pattern(n)

C language

 

#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,j;
    printf("Program to create * pyramid\n");
    for (i=5; i>=0; i--) {
        for (j=0; j<i; j++) {
            printf("*");
        }
        printf("\n");
    }
}

 

Python pattern programming – 4

starpattern04

 

 

 

 

 

 

def pattern(n):
    for i in range(n,0,-1):
        for j in range(0,i):
            print("*",end="")
        print("\n")

n=5
pattern(n)

 



Python pattern programming – 5

starpattern05

 

 

 

 

Python language

def pattern(n):
    for i in range(0,n+1):
        for k in range(n,i,-1):
            print(" ",end="")
        for j in range(0,i):
            print("*",end="")
        print("\r")

n=5
pattern(n)

C language

 

#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,j;
    printf("Program to create * pyramid\n");
    for (i=0; i<=5; i++) {
        for (j=5; j>=i; j--) {
            printf(" ");
        }
        for (int k=0; k<=i; k++) {
            printf("*");
        }
        printf("\n\n");
    }
}

 

Python pattern programming – 6

starpattern06

 

 

 

 

 

def pattern(n):
    for i in range(0,n+1):
        for k in range(n,i,-1):
            print(" ",end="")
        for j in range(0,i):
            print("* ",end="")
        print("\r")

n=5
pattern(n)

Python pattern programming – 7

starpattern07

 

 

 

 

 

def pattern(n):
    for i in range(n,0,-1):
        for k in range(n,i,-1):
            print(" ",end="")
        for j in range(0,i):
            print("* ",end="")
        print("\r")

n=5
pattern(n)

Python pattern programming – 8

starpattern08

 

 

 

 

 

def pattern(n):
    for i in range(n,0,-1):
        for k in range(n,i,-1):
            print(" ",end="")
        for j in range(0,i):
            print("*",end="")
        print("\r")

n=5
pattern(n)

 

Go to: http://tosal.in/python-pattern-programming-part-2/