This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webbrowser | |
class Movie(): | |
"""this classs provides a way to store movies related infornation""" | |
VALID_RATINGS = ['G', 'PG', 'PG1-3', 'R'] | |
def __init__(self, movie_title, movie_storyline, poster_image, trailer_youtube): | |
self.title = movie_title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webbrowser | |
import os | |
import re | |
# Styles and scripting for the page | |
main_page_head = ''' | |
<head> | |
<meta charset="utf-8"> | |
<title>Fresh Tomatoes!</title> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for a in range(1, 21): | |
if a % 3 == 0: | |
print('fizz') | |
if a % 5 == 0: | |
print('buzz') | |
if a % 3 != 0 and a % 5 != 0: | |
print('fizzbuzz') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fresh_tomatoes | |
import media | |
toy_story = media.Movie("Toy story", "A story of a boy whose toys come to life", | |
"https://en.wikipedia.org/wiki/Toy_Story#/media/File:Toy_Story.jpg", | |
"https://www.youtube.com/watch?v=KYz2wyBy3kc") | |
#print (toy_story.storyline) | |
avatar = media.Movie('Avatar', 'A marine on an alien planet', | |
"https://upload.wikimedia.org/wikipedia/en/b/b0/Avatar-Teaser-Poster.jpg", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Decimals are also the type in python. Without using 'decimals' library, floats would | |
# only give you the 'precise' or closest value but not the acurate one. | |
# Try not to use money and scientific related problems with normal float type | |
# instead use 'decimal' library for calculations, you want acuracy. | |
# Floating point | |
print(1 / 3) | |
print(1 / 2 + 2 / 3) | |
# Decimals fixed prescion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dictionaries are not a sequences but are 'mapping' | |
D = {'food': 'spam', 'quantity': 4, 'colour': 'pink'} | |
print(D) | |
# Changing and calling values is as below | |
print(D['food']) | |
D['quantity'] += 1 | |
print(D) | |
D['food'] = 'jam' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creating a text file --> open('filename.type', 'w') --> 'w' is write | |
# Creating a text file --> open('filename.type', 'r') --> 'r' is read | |
f = open('name.txt', 'w') | |
# Writing data --> always remain string type in document | |
f.write('Allah\nis\nall\nseeing') | |
# Flush buffers the output data to your hard drive | |
f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import * | |
from tkinter import ttk | |
from tkinter import messagebox | |
class Feedback: | |
'''This is a form for fun''' | |
def __init__(self, master): | |
master.title('Feedback') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creating a list | |
L = [123, 'spam', 1.23] | |
print(L) | |
print(len(L)) | |
# Indexing | |
print(L[0]) | |
# slicing | |
print(L[:1], L[:-1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sets are unordered collections of unique and immutable objects, sets are useful for common tasks | |
# such as filtering out duplicates, isolating differences, and performing order-neutral | |
# equality tests without sorting in lists, strings, and all other iterable objects | |
# Creating sets --> set('elements') or {'elements'} | |
X = set("ahmed") | |
print(X) | |
Y = {'z', 'a', 'h', 'i', 'd'} | |
print(Y) |
OlderNewer