# Python Programmers



## yerma (Jun 20, 2014)

Hi if you happen to know python please feel free to post a snippet of your code and let me know something interesting about it.

here's mine:


import pygame,sys
from pygame.locals import *


pygame.init()
FPS = 150
fpsClock = pygame.time.Clock()

green=(0,255,0)
red=(255,0,0)
white=(255,255,255)
yellow=(0,0,255)
step_initial_pos=1
pos=step_initial_pos

screeendisplay = pygame.display.set_mode((800,600),0,32)
pygame.display.set_caption("Yakshy's Adventure")
#screeendisplay.fill(white)
def rectstays():
pygame.draw.rect(screeendisplay,red,(30, 500, 40, 80))

#green polka dots for illusiom of motion


def step1(pos):

if pos<800:

x=30
xx=1
x=x+pos*xx
y=100
x1=20
y1=25
pygame.draw.circle(screeendisplay,green,(x, y), 5)
x+=x1
y+=y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
x-=x1
y+=y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
x+=x1
y+=y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
x-=x1
y+=y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
x+=2*x1
y-=2*y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
pos+=1

rectstays()
return(pos)
else:
pos=1
rectstays()
return(pos)




def step2(pos):

screeendisplay.fill(white)
step1(pos)
rectstays()

step=1
while True:
pos=step1(pos)
step2(pos)
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
fpsClock.tick(FPS)


the code renders a flock of six birds flying and red painted building with no doors.


----------



## yerma (Jun 20, 2014)

yerma said:


> Hi if you happen to know python please feel free to post a snippet of your code and let me know something interesting about it.
> 
> here's mine:
> 
> ...


Indention was messed up

some pick to put things into prespective




















i am wondering if some one in some corner of this earth would run this code, if it happens to be you please replay with screen shots as a proof of this poignant event.


Regards,
Yerma


----------



## Solrac026 (Mar 6, 2012)

My code is much too long to post here, but it's available here https://github.com/CharlieTheProgrammer/ComputerVisionWorks/blob/master/MotionDetector.py

This algorithm detects motion and whether there are people in the video stream, whether it's a live stream or not. If it does, it puts a small green box around them.


----------



## martinkunev (Mar 23, 2017)

@yerma Identation was messed up so you decided posting pictures is the solution?

Anyway, I don't get the point of this thread.


----------



## yerma (Jun 20, 2014)

This Thread is pointless.


----------



## WhatIsYourConfirmationBias (May 10, 2018)

Thought this thread was about people who actually train snakes...A bit disappointed!


----------



## knitsix (Jun 21, 2018)

dude do you even stackoverflow?


----------



## Abraxas (May 28, 2011)

knitsix said:


> dude do you even stackoverflow?


I feel like every computer science program at every university should include an introduction to git-hub and stackoverflow in the first semester.


----------



## knitsix (Jun 21, 2018)

Abraxas said:


> I feel like every computer science program at every university should include an introduction to git-hub and stackoverflow in the first semester.


I actually expect people to be able to google because if you choose a cs degree you're probably already spending a lot of time at the computer


----------



## g_w (Apr 16, 2013)

Does "Hello, World" count?


----------



## Abraxas (May 28, 2011)

knitsix said:


> I actually expect people to be able to google because if you choose a cs degree you're probably already spending a lot of time at the computer


If you actually believe "google it" is going to teach you good programming habits when it comes to scripting with git, you have my sympathy.


----------



## knitsix (Jun 21, 2018)

Abraxas said:


> If you actually believe "google it" is going to teach you good programming habits when it comes to scripting with git, you have my sympathy.


Fortunately I don't, thanks anyway for your sympathy


----------



## Trec93 (Jan 31, 2015)

```
/* I recommend wrapping your code into [CODE| here [/CODE|  and use comments within your code */

/* 
        github stackoverflow or whatnot..
        this is a comment block 
        within java and c++ btw
*/
```


```
if pos < 800:
    x=30
    xx=1
    x=x+pos*xx
    y=100
    x1=20
    y1=25
    pygame.draw.circle(screeendisplay,green,(x, y), 5)
    x+=x1
    y+=y1
    pygame.draw.circle(screeendisplay,green,(x,y), 5)
    x-=x1
    y+=y1
    pygame.draw.circle(screeendisplay,green,(x,y), 5)
    x+=x1
    y+=y1
    pygame.draw.circle(screeendisplay,green,(x,y), 5)
    x-=x1
    y+=y1
    pygame.draw.circle(screeendisplay,green,(x,y), 5)
    x+=2*x1
    y-=2*y1
    pygame.draw.circle(screeendisplay,green,(x,y), 5)
    pos+=1
    rectstays()
    return(pos)
else: 
    pos=1
    rectstays()
    return(pos)
```
I'd also replace that with some kind of a for loop, you draw a circle 6 times based on x y coordinates :tongue:


----------

