New Post

Python Code || Path Planning with Grey Wolf Optimization (GWO) ~xRay Pixy

Image
Learn how to implement an obstacle-avoiding path planning for a robot using the Grey Wolf Optimization (GWO) in a static environment. #optimization #algorithm #metaheuristic #robotics #deeplearning #ArtificialIntelligence #MachineLearning #computervision #research #projects #thesis #Python

Python For Beginners - Python Basics

PYTHON FOR BEGINNERS

# Variables: Used to hold Values

x = 200

y = 2

z = x+y

print(z)

OUTPUT: 202

# Careating Strings in Python

r = 'Create stings'

print(r)

d = 'Don\'t Give Up'

print(d)

OUTPUT  
Create stings

Don't Give Up
#Hold Values in Strings
val = 50
disp = 'My Value is %s'
print(disp % val)
OUTPUT: My Value is 50


#placeholder different variables - replace stings
msg = '%s: Python is good'
msg2 = '%s: Yes'
c1 = 'Roy'
c2 = 'Jhon'
print(msg % c1)
print(msg2 % c2)

OUTPUT  
Roy: Python is good
Jhon: Yes

#Hold Multiple Values 
Hold= 'Add %s and %s'
num1 = 23
num2 = 65
print(Hold % (num1,num2))
OUTPUT: Add 23 and 65

#String Multiplication
print(3 * 'R')
OUTPUT: RRR

#How to use Space/Tab
Space = ' ' * 10
print('%s Hello' % Space)
print()
print('%s Life = Peace' % Space)

OUTPUT  : 
           Hello

           Life = Peace

#Create a String List and access Values from it.
SimpleList = ('Peace, Smile, Nature, Birds, Animals')
#Display My List
print(SimpleList)
OUTPUT: Peace, Smile, Nature, Birds, Animals

MyList = ['Peace', 'Smile', 'Nature', 'Birds', 'Animals']
print(MyList[2])

OUTPUT: Nature
print(MyList[1:3])
OUTPUT: ['Smile', 'Nature']

#Add a new item to the List
MyList.append('Care')
print(MyList)
OUTPUT : ['Peace', 'Smile', 'Nature', 'Birds', 'Animals', 'Care'] 

#Remove Item from List
del MyList[4]
print(MyList)
OUTPUT : ['Peace', 'Smile', 'Nature', 'Birds', 'Care'] 

#Join Multiple List
L1 = ['Math Digits']
L2 = [0,1,2,3,4,5,6,7,8,9]
print(L1 + L2)

OUTPUT : ['Math Digits', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 

#IF Else Statements
#Indentation: use same number of spaces else indentation error will occur
a = 10;
if (a>=50):
    print('a is Greater')
else:
    print('a is less than 50')

OUTPUT: a is less than 50

#IF and ElseIF statement
b = 10;
if (b>=50):
    print('b is Greater')
elif (b == 50):
    print('b is equal to 50')
else:
    print('b is less than 50')

OUTPUT: b is less than 50

#Conditions Combination
c = 12
if (c<=5 or c>= 10):
    print('Today is Your Birthday')
    print('Happy Birthday To You :)')
else:
    print('Every Day is New Day!')

OUTPUT: 
Today is Your Birthday
        Happy Birthday To You :)

#FOR LOOP: Print any String Multiple Time
for x in range (0,5):
    print('Good Day!')

OUTPUT: 
Good Day!
Good Day!
Good Day!
Good Day!
Good Day!

#FOR LOOP: Print String and Values
for x in range (0,3):
    print('Student %s' % x)

OUTPUT: 
Student 0
Student 1
Student 2

#Display Color List
ListC = ['red','black','green','blue','yellow']
for r in ListC:
    print(r)

OUTPUT: 
red
black
green
blue
yellow

#While Loop
x = 5
y = 32
while (x<16 and y<65):
    x = x+5
    y = y+6
    print(x,y)
OUTPUT:
10 38
15 44
20 50

#Function in Python: Name, Parameter, and Body
def fun(name):
    print('Hello %s' % name)

#Function Calling
fun('Roxy')

OUTPUT: Hello Roxy

#Variable and Scope
def var():
    v1 = 2
    v2 = 3
    return v1*v2
print(var())

OUTPUT: 6

#Time
import time
print(time.asctime())

OUTPUT: Wed Oct  5 13:31:04 2022






Comments

Popular Post

PARTICLE SWARM OPTIMIZATION ALGORITHM NUMERICAL EXAMPLE

Cuckoo Search Algorithm for Optimization Problems

Particle Swarm Optimization (PSO)

PSO (Particle Swarm Optimization) Example Step-by-Step

how is the LBP |Local Binary Pattern| values calculated? Step-by-Step with Example

PSO Python Code || Particle Swarm Optimization in Python || ~xRay Pixy

Bat algorithm Explanation Step by Step with example

Grey Wolf Optimization Algorithm

Grey Wolf Optimization Algorithm Numerical Example

Whale Optimization Algorithm Code Implementation || WOA CODE || ~xRay Pixy