(use the Space key to navigate through all slides)
Prof. Andrea Gallegati |
Prof. Dario Abbondanza |
Its developers want it to be fun to use.
The name was a tribute to the British comedy group Monty Python.
@andreagalle ➜ /workspaces/CIS1051-python (master) $ python
Python 3.12.1 (main, Dec 12 2024, 22:30:56) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('\n Hi guys! ¯\\_(ツ)_/¯ \n') # this is a comment, on the left there is a function
Hi guys! ¯\_(ツ)_/¯
>>>
The President of the United States,
Donald Trump,
has been meeting with Congress and Senate
to discuss plans for the economy.
Wall Street and taxes are among the main topics
of discussion.
The President of the United States,
Donald Trump,
has been meeting with Congress and Senate
to discuss plans for the economy.
Wall Street and taxes are among the main topics
of discussion.
import re
with open("doc/document.txt", "r") as file:
text = file.read()
print("\n" + text + "\n")
replacements = {
"President": "Supreme Leader",
"United States": "The Banana Republic",
"Donald Trump": "Barack Obama",
"Congress": "The Honorable Council of Elders",
"Senate": "The High Council of Wise Ones",
"House of Representatives": "The Assembly of the People",
"economy": "banana economy",
"Wall Street": "Banana Street",
"taxes": "banana tariffs",
"stock market": "banana market"
}
for old, new in replacements.items():
text = re.sub(old, new, text)
with open("doc/funny_document.txt", "w") as file:
file.write(text)
print("\n ... and the replacement is complete! \n")
print("\n" + text + "\n")
The Supreme Leader of the The Banana Republic, Barack Obama,
has been meeting with The Honorable Council of Elders and The High Council of Wise Ones to discuss plans for the banana economy.
Banana Street and banana tariffs are among the main topics of discussion.
The President of the United States,
Donald Trump,
has been meeting with Congress and Senate
to discuss plans for the economy.
Wall Street and taxes are among the main topics
of discussion.
from PIL import Image
from IPython.display import display
with Image.open("img/lgbt-logo.jpg") as im:
display(im.convert("L")) # opts: L, 1, RGB, "P", palette=Image.ADAPTIVE, colors=256
from PIL import Image, ImageSequence
from IPython.display import display
im = Image.open("img/monty-python.gif")
frames = [frame.copy() for frame in ImageSequence.Iterator(im)]
frames.reverse()
frames[0].save('img/reverse-monty-python.gif', save_all=True,
append_images=frames[1:], loop=0)
Get data from the keyboard, a file, the network
Send data on the screen, to a file, over the network
Basic math operations (+/-*)
Check for certain conditions and run the appropriate code
Perform some action repeatedly, usually with a little variation
languages people speak.
Not designed by people, they evolved naturally.
designed by people for specific applications.
Natural languages are full of ambiguity, which people deal with by using contextual clues and other information.
Formal languages are designed to be nearly or completely unambiguous, which means that any statement has exactly one meaning, regardless of context.
As a result, they are often verbose. Formal languages are less redundant and more concise
In order to make up for ambiguity and reduce misunderstandings, natural languages employ lots of redundancy.
Formal languages, simply
mean exactly what they say.
Natural languages are full of idiom and metaphor ...
poetry
Words are used for their sounds, meaning, and the whole poem together creates an effect or emotional response. Ambiguity is not only common but often deliberate.
The literal meaning of words is more important, and the structure contributes more meaning.
The meaning of a computer program is unambiguous and literal, and can be understood entirely its analysis.
A Framework created by Hakim El Hattab and contributors
to make stunning HTML presentations