Internet Protocols and Support
https://docs.python.org/3.4/library/internet.html
https://docs.python.org/3.4/library/urllib.request.html
====================================
None keyword
example: i = A
i = None
Building lists
evens_to_50 = [i for i in range(51) if i % 2 == 0]
print(filter(lambda x: x % 3 == 0, my_list))
>>>for i in filter(lambda x: x[0] == “P”, languages):
print(i)
Python
>>> languages[2]
‘Python’
Welcome to an intro level explanation of bitwise operations in Python!
Bitwise operations might seem a little esoteric and tricky at first, but you’ll get the hang of them pretty quickly.
class Fruit(object):
“””A class that makes various tasty fruits.”””
def __init__(self, name, color, flavor, poisonous):
self.name = name
self.color = color
self.flavor = flavor
self.poisonous = poisonous
def description(self):
print “I’m a %s %s and I taste %s.” % (self.color, self.name, self.flavor)
def is_edible(self):
if not self.poisonous:
print “Yep! I’m edible.”
else:
print “Don’t eat me! I am super poisonous.”
lemon = Fruit(“lemon”, “yellow”, “sour”, False)
lemon.description()
lemon.is_edible()
class PartTimeEmployee(Employee):
def calculate_wage(self, hours):
self.hours = hours
return hours * 12.00
def full_time_wage(self, hours):
return super(PartTimeEmployee, self).calculate_wage(hours)
class Car(object):
condition = “new”
def __init__(self, model, color, mpg):
self.model = model
self.color = color
self.mpg = mpg
def display_car(self):
print “This is a %s %s with %s MPG.” % (self.color, self.model, self.mpg)
def drive_car(self):
self.condition = “used”
my_car = Car(“DeLorean”, “silver”, 88)
print(my_car.condition)
my_car.drive_car()
print(my_car.condition)
class ElectricCar(Car):
def __init__(self, model, color, mpg, battery_type):
self.model = model
self.color = color
self.mpg = mpg
self.battery_type = battery_type
my_car = ElectricCar(“Dodge Stratus”, “white”, 18,”molten salt”)
{Is there need to re-define everything??}
my_list = [i**2 for i in range(1,11)]
# Generates a list of squares of the numbers 1 – 10
f = open(“output.txt”, “w”)
for item in my_list:
f.write(str(item) + “\n”)
f.close()
=============
with open(“text.txt”, “w”) as textfile:
textfile.write(“Success!”)
with open(“text.txt”, “w”) as my_file:
my_file.write(“I am Sam”)