Attachment 'Sav_2_graphfn(simple, different functions).py'

Download

   1 import sys, pygame
   2 from math import *
   3 
   4 pygame.init()
   5 
   6 print "y =",
   7 strx = raw_input().strip()
   8 
   9 XD = 640
  10 YD = 480
  11 
  12 screen = pygame.display.set_mode((XD, YD))
  13 y = x = 0
  14 i = 0.03
  15 for j in xrange(1000):
  16  for event in pygame.event.get():
  17   if event.type == pygame.QUIT: sys.exit()
  18  
  19  y = eval(strx)
  20   
  21  screen.fill((255, 255, 0), (XD/2+x*33, YD/2-y*33, 1, 1))
  22  
  23  x += i
  24  i = -(abs(i) + 0.03)*i/abs(i)
  25  pygame.display.flip()
  26 while 1:
  27  for event in pygame.event.get():
  28   if event.type == pygame.QUIT: sys.exit()

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.