Skip to content

Instantly share code, notes, and snippets.

@raymondberg
Created January 25, 2021 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raymondberg/22cedfab9a5d29efbe82a33f1e5df00e to your computer and use it in GitHub Desktop.
Save raymondberg/22cedfab9a5d29efbe82a33f1e5df00e to your computer and use it in GitHub Desktop.
My First Python Scripts were written on Jan 4 of 2007. Here they are for posterity
from itertools import count
def generate_primes(stop_at=None):
primes = []
for n in count(2):
if stop_at is not None and n > stop_at:
return
composite = False
for p in primes:
if not n % p:
composite = True
break
elif p**2 > n:
break
if not composite:
primes.append(n)
yield n
for i in generate_primes(): # iterate over ALL primes
if i > 100: break
print i
import sys, os
def getline():
return sys.stdin.readline()
print 'What is your name?'
name = getline()
print 'I think you said your name was %s' % name
print 'Did I get that right?'
response = getline()
if(response == 'Yes'):
print 'Yay for me'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment