Early Computers

In 1800, French industrialist J. M. Jacquard invented a loom to weave fabrics with complex designs. The loom was controlled by punched paper cards and has been called a “specialized graphics computer.” A few years later, Charles Babbage (1792-1871), a math professor at Cambridge, designed what he called the “difference engine” and the “analytical engine” …

Classes and Objects in Python

#define the Vehicle class class Vehicle: name = “” kind = “car” color = “” value = 100.00 #class function named description #we define a variable named desc_str and use #string formatting inside the string def description(self): desc_str = “%s is a %s %s worth $%.2f.” % (self.name, self.color, self.kind, self.value) return desc_str #instantiate two …

Conditions in Python

#Conditions x = 2 print(x==2) #prints out True print(x==3) #prints out False print(x<3) #prints out True #Using “and” + “or” keywords name = “John” age = 23 if name == “John” and age == 23: print(“Your name is John, and you are also 23 years old.”) if name == “John” or name == “Rick”: print(“Your …

Basic String Operations in Python

#Basic_String_Operations # <<—this is a comment #can use double or single quotes” astring = “Hello world!” astring2 = ‘Hello world!’ #enclose single quotes inside double quotes print(“single quotes are ‘ ‘”) #print the length of a string print(len(astring)) #print index of string w/ first occurrence of the letter #”o” print(astring.index(“o”)) #count the number of “ls” …

Design a site like this with WordPress.com
Get started