INFO 253B: Backend Web Architecture
Kay Ashaolu
A programming language is a formal language, which comprises a set of instructions used to produce various kinds of output. Programming languages are used in computer programming to create programs that implement specific algorithms.
def hello_world():
print("Hello World!")
if __name__ == "__main__":
hello_world()
def integers_demo():
testInt = 5
testFloat = 2.9
return testInt * testFloat
def string_demo():
testString = "hello "
testNumTimes = 3
return testString * testNumTimes
if __name__ == "__main__":
print(integers_demo())
print(string_demo())
def string_demo_length():
myString = "This is a new string"
return len(myString)
def string_demo_substring():
myString = "This is a new string"
return myString[3:7]
def string_demo_reverse():
myString = "This is a new string"
return myString[::-1]
if __name__ == "__main__":
print(string_demo_length())
print(string_demo_substring())
print(string_demo_reverse())
def string_demo_formatting():
numTimes = 3
temperature = 50.7
message = "she sells seashells by the seashore"
return f"I would like to write {message} {numTimes} times. By the way the temperature outside is {temperature} degrees outside."
if __name__ == "__main__":
print(string_demo_formatting())
def testLists():
mylist = []
mylist.append(1)
mylist.append(2)
mylist.append(3)
print(mylist[0]) # prints 1
print(mylist[1]) # prints 2
print(mylist[2]) # prints 3
for x in mylist:
print(x)
if __name__ == "__main__":
testLists()
def testDictionaries():
phonebook = {
"John" : 938477566,
"Jack" : 938377264,
"Jill" : 947662781
}
del phonebook["John"]
return phonebook
if __name__ == "__main__":
print(testDictionaries())