Www.ecedept.com



SIMULATE ELLIPTICAL ORBITS IN PYGAMESIMULATE BOUNCING BALL USING PYGAMEimport pygame import math from time import * pygame.init() screen = pygame.display.set_mode((700, 700)) black = (0, 0, 0) yellow = (255, 255, 0) blue = (0, 0, 255) ex = 50 ey = 350 oe = 0 a=1 while a==1: screen.fill(black) ex = math.cos(oe) * 300 + 350 ey = -math.sin(oe) * 300 + 350 oe += .002 remove pygame.draw.circle(screen, yellow, (350,350), 50) pygame.draw.circle(screen, blue, (int(ex), int(ey)), 15) pygame.display.flip() sleep(.010) for event in pygame.event.get(): if event.type == pygame.QUIT: a = 0 pygame.quit()import pygame import math from time import * pygame.init() screen = pygame.display.set_mode((700, 700)) white = (255, 255, 255) yellow = (255, 255, 0) blue = (0, 0, 255) ex = 50 ey = 350 oe = 0 om = 0a=1 while a==1: ??? screen.fill(white) ?? ??? ex = math.cos(oe) * 300 + 350 ??? ey = -math.sin(om) * 300 + 350??? oe += 0.002??? om += 0.01?????? pygame.draw.circle(screen, blue, (int(ex), int(ey)), 15) ??? pygame.display.flip() ??? sleep(.010)??? for event in pygame.event.get(): ??????? if event.type == pygame.QUIT: ??????????? a = 0 pygame.quit()PROGRAM FOR COMMAND LINE ARGUMENTS ( WORD COUNT )PROGRAM TO FIND MOST FREQUENT WORDS IN A TEXT READ FROM A FILERemove this Linefrom sys import argv from collections import Counter f = open( argv[1] ," r ") c = Counter ( f.read( ) . split( ) ) print( " Number of words in the file : " , c )from collections import Counter f=open( "ex.txt" , "r" ) c=Counter( f.read( ) . split( ) ) print("Number of words in the file :",c)INPUT (ex.txt)panimalar anna panimalar anna panimalar annauniversityOUTPUTsam@syse:~$ python cmd.py ex.txt ('Number of words in the file :', Counter({'panimalar': 3, 'anna': 2, 'annauniversity': 1}))INPUT (ex.txt )panimalar anna panimalar anna panimalar annauniversityOUTPUTsam@syse:~$ python coun.py ('Number of words in the file :', Counter({'panimalar': 3, 'anna': 2, 'annauniversity': 1})) ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download