Skip to content

Instantly share code, notes, and snippets.

@AhmedZahid098
AhmedZahid098 / webdev_online_resources.md
Created November 14, 2018 14:02 — forked from bradtraversy/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
class Worker:
def __init__(self, name, pay):
self.name = name
self.pay = pay
def firstName(self):
return self.name.split()[0]
def giveRaise(self, percent):
self.pay *= (1.0 + percent)
# There are three ways to tests type in python
L = [None]
# using type syntx
if type(L) == type([]):
print('yup')
# using type name
if type(L) == list:
print('yup')
# Tuples are sequences, like lists, but they are immutable, like strings
# Syntactically, they are normally coded in parentheses instead of square brackets,
# and they support arbitrarytypes, arbitrary nesting, and the usual sequence operations.
# A Tuple and its length is as below
T = (1, 'a', 2, 'b', 3, 'c')
print (T)
print(len(T))
# Indexing
# Importing builtin Libraries
import math
import random
import sys
import re
# Printing System Detail
print (sys.platform)
# Two raised to the power hundred
# 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)
# Creating a list
L = [123, 'spam', 1.23]
print(L)
print(len(L))
# Indexing
print(L[0])
# slicing
print(L[:1], L[:-1])
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')
# 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()
# 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'