Skip to content

Instantly share code, notes, and snippets.

@Battleroid
Last active December 15, 2015 22:39
Show Gist options
  • Save Battleroid/5334760 to your computer and use it in GitHub Desktop.
Save Battleroid/5334760 to your computer and use it in GitHub Desktop.
Trying to learn some python.
import os
def hello(name):
print 'Hello,', name
os.system('pause')
hello('Casey')
import os
# Making list of certain size and entering values them spitting them out.
names = [0] * 3
for index in range(len(names)):
names[index] = raw_input('What is your name?\n')
for i in names:
print i
os.system('pause')
import os
# One is a dog, the rest are cats.
names = ['Spooky', 'Cinder', 'Checkers', 'Elise', 'Peaches', 'Nigel']
for i in names:
if i != 'Elise':
print i,'is not a dog'
else:
print i,'is a dog'
os.system('pause')
import os
amt = raw_input('How many items: ')
amt = int(amt)
names = [];
for i in range(0, amt):
tmp = raw_input('Item ' + str((i + 1)) + ': ')
names.append(tmp)
names.sort()
for item in names:
print(item)
os.system('pause')
import os
# Time
from time import localtime
stuff = {3: 'Study', 6: 'Go to class'}
cur_time = localtime()
cur_hour = cur_time.tm_hour
print 'It is',cur_hour
for i in sorted(stuff.keys()):
if cur_hour == i:
print stuff[i]
break
else:
print 'Nothing to do right now.'
os.system('pause')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment