Posts

Showing posts from April, 2018

XHTML/ CSS - iframes

You can add styling to iframe elements to make them responsive to the website.  https://www.youtube.com/watch?v=X4t0JxiBeO0

Coding for UWAV

Well, here we go again for the third time, but I'm sure it won't be the last time. I am going to write the code to give the elements in my website structure etc. I'm first going to start with the dashboard header with links and a login window. It will be positioned absolutely, etc.

Python 3.4 - Sorting Custom Objects

You can sort objects in a list using the operator module. By creating a class with functions that identify and label the values of your dictionary you can use that info to sort. from operator import attrgetter class User: def __init__ ( self , x , y): self .name = x self .user_id = y def __repr__ ( self ): return self .name + ":" + str ( self .user_id) users = [ User( 'Zach' , 38 ) , User( 'Mel' , 38 ) ] for User in users: print (User) for User in sorted (users , key =attrgetter( 'name' )): print (User) https://www.youtube.com/watch?v=fS71qdg5WOY

Python 3.4 - Dictionary Multiple Key Sort

You can sort data and use it for different purposes: from operator import itemgetter user = { 'fname' : 'Matt' , 'lname' : 'Fassnacht' } , { 'fname' : 'Jim' , 'lname' : 'Fassnacht' } for x in sorted (user , key =itemgetter( 'fname' )): print (x) https://www.youtube.com/watch?v=avthXghx0a0

Python 3.4 - Counter

You can use a program to count the words and also other things: from collections import Counter text = 'Creeds and schools in abeyance, Retiring back a while sufficed at what they are, but never forgotten, I harbor for good or bad, I permit to speak at every hazard, Nature without check with original energy.' words = text.split() counter = Counter(words) top_three = counter.most_common( 3 ) print (top_three) https://www.youtube.com/watch?v=5eO5-w2g1Ik

Python 3.4 - Dictionary Calculations

You can get certain values and keys and information from dictionaries in different ways.  http://buildingskills.itmaybeahack.com/book/python-2.6/html/p02/p02c05_maps.html kitties = { 'Lizzy' : 7 , 'stretch' : 8 , 'bronte' : 9 } min_age = min ( zip (kitties.values() , kitties.keys())) print (min_age) https://www.youtube.com/watch?v=E1GueQ5ULc8

Python 3.4 - Finding Largest or Smallest Items

Importing the heapq function allows for us to get specific data from a list or dictionary: import heapq grades = [ 32 , 42 , 54 , 56 , 66 , 78 , 99 ] print (heapq.nlargest( 3 , grades)) /Users/mattfassnacht/PycharmProjects/untitled6/venv/bin/python /Users/mattfassnacht/PycharmProjects/untitled6/functions.py [99, 78, 66] Process finished with exit code 0 https://www.youtube.com/watch?v=iiQqilwChw4

Python 3.4 - Bitwise Operators

Bitwise operators treat numbers as a string of bits.  https://wiki.python.org/moin/BitwiseOperators https://www.youtube.com/watch?v=frwqnS9ICxw

Python 3.4 - Map

The map function allows you to quickly perform a function on a set of items.  https://www.youtube.com/watch?v=Z8Cu-8brldc

Python 3.4 - Struct

Data sometimes needs to be unpacked, packed, convert, transferred, etc. The packing function form the struct module achieves this action. from struct import * packed_data = pack( 'iif' , 3 , 44 , 4.5 ) print (packed_data) print (calcsize( 'i' )) print (calcsize( 'f' )) print (calcsize( 'iif' )) original_data =unpack( 'iif' , packed_data) print (original_data) https://www.youtube.com/watch?v=PGAtCGqt06U

Python 3.4 - Cropping Images

https://www.youtube.com/watch?v=SiOBAhUiNCc

Python 3.4 - Pillow

Pillow: "It adds support for opening, manipulating, and saving many different image file formats." http://www.pythonforbeginners.com/gui/how-to-use-pillow from PIL import Image img = Image.open( 'hand.png' ) img.show() https://www.youtube.com/watch?v=_H9uPRJWMNk

Python 3.4 - Min, Max, and Sorting Dictionaries

 Dictionaries have two elements in them. A key (word) and a value (definition). If you want to sort these values you can. You can pull the max value, there's a lot you can do, let's look: dict = { 'goog' : 540.43 , 'yahoo' : 456.45 , 'amazon' : 654.43 } print ( min ( zip (dict.values() , dict.keys()))) print ( max ( zip (dict.values() , dict.keys()))) print ( sorted ( zip (dict.values() , dict.keys()))) https://www.youtube.com/watch?v=U5I-2UZBOVg

Python 3.4 - Lamdba

Lambda is a stand-alone function that allows for single-item functionality. answer = lambda x: x* 7 print (answer( 5 )) http://www.secnetix.de/olli/Python/lambda_functions.hawk https://www.youtube.com/watch?v=Xe1tnfl4jDY

Python 3.4 - Zip

The zip function takes two lists and puts them together. It will create positions for the items in the list: List = [ 'matt' , 'tom' , 'taylor' ] List2 = [ 'han' , 'leia' , 'luke' ] names = zip (List , List2) for a , b in names: print (a , b) https://www.youtube.com/watch?v=cTXHmOt7Rwc

Python 3.4 - Unpack List or Tuples

 There are multiple ways to separate items in a list or tuple: list = [ 'Yesterday' , 'Beer' , 8.51 ] date , item , price = [ 'Yesterday' , 'Beer' , 8.51 ] print (list) print (item) You can access a list and the items within it using functions and then have the function do something with those items. def drop_first_last (grades): first , *middle , last = grades avg = sum (middle) / len (middle) print (avg) drop_first_last([ 65 , 75 , 65 , 88 , 99 , 34 , 22 , 10 , 99 ]) https://www.youtube.com/watch?v=XhXOsgdC9h0

Python 3.4 - Threading

The threading module allows your program to run two separate functions at once. This can be advantageous and/ or problematic depending on what you want your program to do. https://www.tutorialspoint.com/python/python_multithreading.htm import threading class Matt(threading.Thread): def run ( self ): for _ in range ( 10 ): print (threading.currentThread().getName()) messenger1 = Matt( name = 'send messeages' ) messenger2 = Matt( name = 'recieve messages' ) messenger1.start() messenger2.start() https://www.youtube.com/watch?v=WaXK8G1hb_Q

Python 3.4 - Multiple Inheritance

 You can create a class that can draw on other classes to use their functions. class Mario(): def move ( self ): print ( 'i am moving' ) class Shroom(): def eat_shrooms ( self ): print ( 'i am big' ) class BigMario(Mario , Shroom): pass mario1 = BigMario() mario1.move() mario1.eat_shrooms() https://www.youtube.com/watch?v=YCEVvs5BhpY

Python 3.4 - Inheritance

Objects can inherit functions from other classes by grouping them together. Once grouped together the functions of both classes can be called upon.  class Parent(): def print_last_name ( self ): print ( 'Fassnacht' ) class Child(Parent): def print_first_name ( self ): print ( 'Matt' ) child1 = Child() child1.print_first_name() child1.print_last_name() https://www.youtube.com/watch?v=oROcVrgz91Y

Python 3.4 - Class vs Instance Variables

A class variable is applied to all objects in that class. If you use an instance variable it is only used for that one instance, perhaps not all objects.  https://www.youtube.com/watch?v=qSDiHI1kP98

Python 3.4 - Init

The init function is odd but it will run automatically, first for any object in a class. To create the init function you need this: __init__ (two underscores on each side). class Lakers: def __init__ ( self ): print ( 'Hey man ...Hey...!' ) def lose ( self ): print ( 'Loser!' ) laker1 = Lakers() laker1.lose() https://www.youtube.com/watch?v=G8kS24CtfoI

Python 3.4 - Classes and Objects

Classes can be created and store set information and functions. Only objects relating to their class will be able to use the data within their corresponding class. https://www.youtube.com/watch?v=POQIIKb1BZA

Python 3.4 - Exceptions

Sometimes users can input data that might throw our program off and break it. We don't want our programs to stop running every time a user does something wrong. Instead we need to do something with these errors, and make sure there is a fail-safe for our programs to continue running. while True : try : kitties = int ( input ( 'How many cats is too many? \n ' )) print ( 18 /kitties) break except ValueError : print ( "Try again." ) except ZeroDivisionError : print ( "Good answer, try again" ) except : break finally : print ( 'Thank you for trying' ) https://www.youtube.com/watch?v=1cCU0owdiR4

Python 3.4 - Downloading Files from the Web

You can access and download data from the web and store it. You can organize the data as you store it. https://www.youtube.com/watch?v=MjwWzBiAMck

Python 3.4 - How to Read and Write Files

 You can create files in python in order to add data. To write to an existing or non-existing file you do the following: file = open ( 'main.txt' , 'w' ) file.write( 'Hello' ) file.close()  This would open/ create the file and do whatever action we want to it, add text, and then close it. You can do something similar for reading a file, but you need to add a string to ID the text you want to read: file2 = open ( 'main.txt' , 'r' ) text = file2.read() print (text) file2.close() https://www.youtube.com/watch?v=YV6qm6erphk

Python 3.4 - Modules

Modules can be called on to do functions from a list of functions we've created. Basically, image making a list of functions that you want to use, instead of putting them in our code we can make a separate, let's call it 'external function sheet', to store them in. In order to do this you'll need to import the external function sheet using the import.filename function and when you want to call on a function within your E.F.S. you need to specify the rootfilename like this: filename.functionname(). This with any arguments needed, if needed, will run the function. Again, be sure the files are in the same directory or else specify its location otherwise. The files need to be in the same directory unless you specify otherwise. List of modules: https://docs.python.org/3/py-modindex.html https://www.youtube.com/watch?v=WN4A6iJOUns

Python 3.4 - Downloading Images

Programs do a lot of the work for you, or they should. It also shouldn't be work to get program to do all the work we don't want to do. Take for example this tutorial. If you want to download images from a site you don't have to do it one at a time. You can simply write a function to do it for you. Modules do most of the work for you. This function would save whatever image you downloaded in the file directory for this file.  import urllib.request import random def downloader (image_url): file_name = random.randrange( 1 , 10000 ) full_file_name = str (file_name) + '.jpg' urllib.request.urlretrieve(image_url , full_file_name) downloader(url) https://www.youtube.com/watch?v=GQiLweAoxgQ

Python 3.4 - Dictionary

Dictionaries contain words and definitions. Or a keyword and what is value is. You can store information(data) this way in python. You make a dictionary with a list of keys:values and then use those values however you'd like. Below I have a list of keys (cats) and their corresponding values (how special they are). Again, there's lots we can do with dictionaries: https://www.python-course.eu/dictionaries.php kitties = { 'Lizzy' : ' so special' , 'stretch' : ' super special' , 'bronte' : ' special too' } for k , v in kitties.items(): print (k + v , "Good Kitty" ) https://www.youtube.com/watch?v=BSNFRKG1MfE

Python 3.4 - Sets

 You can use a set to make sure any redundancy is eliminated from a list.A set cannot have two of the same item. groceries = { 'milk' , 'bacon' , 'coffee' , 'milk' , 'eggs' , 'diapers' } print (groceries) if 'milk' in groceries: print ( 'you already have it' ) else : print ( 'you need some' ) /Users/mattfassnacht/PycharmProjects/untitled10/venv/bin/python /Users/mattfassnacht/PycharmProjects/untitled10/string.py {'eggs', 'bacon', 'milk', 'diapers', 'coffee'} you already have it Process finished with exit code 0 https://www.youtube.com/watch?v=23eY8n08pMc

Python 3.4 - Unpacking Arguments

Unpacking a list of arguments can be laborious. But by using the unpacking feature you may let the program do it for you. As seen below, both of the functions call on the data, the unpacked on does it for you, whereas the previous one is coded by hand to call on each argument.  def health_cal (age , apples , cigs): answer = ( 100 -age) + (apples * 3 ) - (cigs * 2 ) print (answer) my_data = [ 38 , 2 , 2 ] health_cal(my_data[ 0 ] , my_data[ 1 ] , my_data[ 2 ]) health_cal(*my_data) https://www.geeksforgeeks.org/packing-and-unpacking-arguments-in-python/ https://www.youtube.com/watch?v=DJ2HSCT6Z8w

Python 3.4 - Variable Arguments

 Your functions may be collecting large amounts of arguments to be used and you don't want to assign an argument for each, or you imply may not know how many arguments someone will input. Either way, you can use the *args and **kwargs arguments to accept different type of variable-length arguments. https://www.protechtraining.com/content/python_fundamentals_tutorial-functions https://www.youtube.com/watch?v=QSTo9F8E6GE

Python 3.4 - Keyword Arguments

 You can make functions that have keywords for arguments. Python will assume that the keywords you assign to the function are the ones in order in relation to the preset argument position (i.e. x, y, z). If you want to assign position you can specify this. def dumb_sentence (name= "matt" , action= 'ate' , item= 'food' ): print (name , action , item) dumb_sentence( 'Lizzy' , 'sleeps' , 'softly' ) https://www.youtube.com/watch?v=DASOXeFFkCg

Python 3.4 - Default Values for Arguments

Functions do things. Functions are made of arguments: " In mathematics , an argument of a function is a specific input in the function, also known as an independent variable. https://en.wikipedia.org/wiki/Argument_of_a_function If I made a function called amount_of_hits_per_boxer I would need to arguments (name, hits) The function would look something like this: def amounts_of_hits_per_boxer (name , hits= 0 ): print (name , hits) amounts_of_hits_per_boxer( 'Tyson =' , 34 )   The output would be Tyson = 34. By giving hits a default value of zero, if there is no input for hits, no 34, than we would just get a return of Tyson = 0. If you don't give arguments default values it can mess up our program, simply stated. https://www.protechtraining.com/content/python_fundamentals_tutorial-functions def get_gender (sex= 'Unknown' ): if sex is 'm' : sex = 'Male' elif sex is 'f' : sex = 'Female' ...

Python 3.4 - Return Values

You can make a function and use inputs and do things with it and return a value. These are called return values. There are simple functions that do something once they are run. You can use functions and import them from saved py pages to use on your website. def happyBirthdayEmily (): print ( "Happy Birthday to you!" ) print ( "Happy Birthday to you!" ) print ( "Happy Birthday, dear Emily." ) print ( "Happy Birthday to you!" ) happyBirthdayEmily() Running happyBirthdayEmily will simply print the statements listed. def lizzy (x , y): total = x + y return total calling the function lizzy from the saved file can draw on the function and use it for whatever prupose https://www.youtube.com/watch?v=xRIzPZlei9I

Pyhton 3.4 - Continue

Continue keeps the loop going. It allows you loop to do whatever else it wants to do outside of that statement. https://www.youtube.com/watch?v=68EhtQbgXRc Lakers_jerseys_taken = [ 8 , 24 , 32 , 34 ] print ( 'These are the jersey \' s still available:' ) for number in range ( 101 ): if number in Lakers_jerseys_taken: print ( 'You must be crazy' ) continue print (number)

Python 3.4 - Comments and Break

Comments won't be printed in your program. They are there for others to be able to understand your code and what you were thinking, if possible.  magicnumber = 99 #This is the magic number, a variable I created. for n in range ( 101 ): #We'll be going through 100 numbers if n is magicnumber: #I think the rest is self explanatory print ( 'You are it!' ) else : print ( "you are not it" )  A break will stop your program from running on that loop, if the conditions are met. This will kick you out of your loop so be careful: magicnumber = 99 for n in range ( 101 ): print ( "you are not it" ) if n is magicnumber: print (n , 'You are it!' ) break In this example the output stops once it reaches the magicnumber and doesn't print for number 100 because the break statement stops the loop.  https://www.youtube.com/watch?v=k6rkvgQkW04

Python 3.4 - Range and While

Range can be used with your for loop. What you would do is access the range of a set of numbers and make it do something with that range of numbers: for x in range ( 13 ): print ( "hello" ) For this range, 13 numbers I made it print hello 13 times. Printing the variable will automatically print the number. More on range: https://www.programiz.com/python-programming/methods/built-in/range While loops can be used to tell a program to do something while something is true or false or other things: http://www.pythonforbeginners.com/control-flow-2/python-for-and-while-loops https://www.youtube.com/watch?v=Neir-vgPyxw

Python 3.4 - For Loop

You can take a list of strings or other data types and do things with them, much like you can do slicing a string. https://www.python-course.eu/python3_for_loop.php https://www.youtube.com/watch?v=llguiJHU0kk

Python 3.4 - Data Types

There are different kinds of data types and there are different uses for them. https://www.youtube.com/watch?v=657yt4gYjRo Data Type Used for Example String Alphanumeric characters hello world, Alice, Bob123 Integer Whole numbers 7, 12, 999 Float (floating point) Number with a decimal point 3.15, 9.06, 00.13 Character Encoding text numerically 97 (in ASCII, 97 is a lower case 'a') Boolean Representing logical values TRUE, FALSE

Python 3.4 - Slicing Strings

user = "Buff McLargeHuge" print (user[ 5 ]) You can access various parts of a string (slice) and do things with them by using square brackets []. There's a lot you can do: https://www.pythoncentral.io/cutting-and-slicing-strings-in-python/ Above I am printing the letter 'M' out.  https://www.youtube.com/watch?v=YbipxqSKx-E

Python 3.4 - Strings

Including text in any aspect of your program, text that will appear on the screen, is a string. You can include any kind of text, of course (i.e. The program may ask a user to enter his or her username, etc). Strings (text) needs to be entered with single or double quotations, you can a do a lot with strings: https://docs.python.org/2.4/lib/string-methods.html In your string, if you ever want to make sure some line of text is included just add a backslash (\) to you text. (i.e. 'It\'s important the \'s in it\'s is included all three times actually.') If you include a backslash and n (\n) it will print the rest of the string on a new line. You can negate this action with an r included here: print(r'hello world') #This will print the raw string. https://www.youtube.com/watch?v=nefopNkZmB4

Python 3.4 - Variable Scope

When creating a function using a variable you need to put the variables above the functions so they can access it: https://www.youtube.com/watch?v=f3TVuuhe-fY

XHTML/ CSS - Submitting Forms

You can create a button for your forms that will allow the user to submit them to the site for use. It is another kind of form and here it is: <input type = "submit" value ="Submit!"/> This will have a button with the word Submit! on it. The <form action ="" method = ""> tag will take whatever data you had the user submit and do things with it.  Method action sends the data in a certain way, but we'll get there later.  https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Passwords / Upload Buttons

A password box is slightly different than a text box. This would show the little dots like a password should. You would add this to your form element: <form> Password: <input type= "password" name ="pword" /> To create an upload button you'll need to create an input tag for "file". Here it is: <input type = "file" name = "filename"/> https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Text Areas

Sometimes you want people to have a text area to input a lot of text. You use the tags <textarea></textarea>. Here's an example: <form> <textarea name = "textfield"> Type something here </textarea> </form> You can change the size of the text field by adding rows ="" and cols = "" to the <textarea> tag. https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Drop Down List

Another element that might be included on a webpage is a drop-down menu:   <form action="/action_page.php">   <select name="cars">     <option value="volvo">Volvo</option>     <option value="saab">Saab</option>     <option value="fiat">Fiat</option>     <option value="audi">Audi</option>   </select>   <br><br>   <input type="submit"> </form> Again the form action sends the data to another page to be worked on. The <select> tags are used to hold the drop-down element. The <option> tags are used to hold and identify the drop down option. The value ID is used to program the data for later use.  https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Check Boxes & Radio Buttons

Radio buttons and check boxes are used on sites all the time. They can be limiters and can help searches. By deselecting and selecting these buttons and boxes you can make your site more useful.  radio buttons: <form action="">   <input type="radio" name="gender" value="male"> Male<br>   <input type="radio" name="gender" value="female"> Female<br>   <input type="radio" name="gender" value="other"> Other </form> Check Boxes: <form action=""> <input type="checkbox" name="vehicle" value="Bike">I have a bike<br> <input type="checkbox" name="vehicle" value="Car">I have a car </form> The form action tag sends the information to wherever you want the form/ data to be sent. https://www.w3schools.com/howto/howto_css_custom_checkbox.asp ...

XHTML/ CSS - Forms

There are many ways to make forms and have people use them. In order to create a form in HTML you need to use the <form> tags. These will go inside the parent tags <body>. It would look something like this: < form >   First name: < input type ="text" name ="fname" size ="" maxlength = "" value =""/>   Last name: < input type ="text" name ="lname"/ > < /form > The input type asks for what kind of input you want. The name is used for css styling. The size changes the size of the text field. The maxlength changes the amount of letters a user can input. Value creates a pre-recorded value in the box before the user inputs.  https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Max Height/ Width

You can resize images or any elements for many reasons. Using the max-width/ height properties let's you manipulate elements. Here's an example: Property Description height Sets the height of an element max-height Sets the maximum height of an element max-width Sets the maximum width of an element min-height Sets the minimum height of an element min-width Sets the minimum width of an element width Sets the width of an element https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Fixed Positioning

Fixed positioning places an element of your webpage in a certain location regardless of user input. If a user is to scroll, the element that is fixed will scroll with the page and remain in its position.  https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Relative Positoning

Relative positioning moves an element relative to where it would be regardless.  https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Absolute Positioning

Absolute positions along with using the top, bottom, left, right positioning properties allows you to move an element wherever you want on a page.  https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Overriding Styles

If you have one page that you want to edit the style on without affecting other pages you can override the external style sheet by just adding back in the <style> tags. Easy-peasy.  Never put the style tags above the external style sheet as it might override your desired style.  https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - External Style Sheets

If you want to change the style to multiple elements on many webpages at the same time you can use external style sheets. This will save you time as you want to make wholesale changes to your site. What you need to do is make another page and save it as a CSS file. You can add all of the elements and how you want to style them on this sheet. If you use this method than you don't need the style tags anymore, you only need to link to the external style sheet you created. Like this: <head>  <link rel = "stylesheet" type = "text/css" href = "filename.css" /> </head> The above will link to the external style sheet. All of the files need to be in the same folder to be able to link correctly. https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Psuedo Elements

Once again, there are many ways to style elements and certain parts of elements that you only want styled. If you want to style the beginning of an element you can create a style sheet for it. If I wanted to style the first letter of <p>Hello world</p> I can do this: <style> p:first-letter {font-size: 30px;} </style> https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS = Child Selector

Elements within another tag are the child of that tag.  (i.e. <html> <body> <body> </html> In this example we see the body is inside the parent tag <html></html> ) If you want to style elements that are within one of the tags you can specify that child by adding the child selector css style tag. It looks like this: <style> div > p {     background-color : yellow ; } </style> <div> <p> fhijfhwfhd </p> </div> The above shows that by using the > sign you are indicating that the child of div is what I want to be style and that's it.  https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - ID's

Once again, there is another way to style elements on a webpage. Using the <div> tags we may want to position/ style multiple elements. But how do we do that using one tag. It would seem to move all the elements within the div tag. ID's help us do this without confusion. < style > #myHeader {     background-color : lightblue ;     color : black ;     padding : 40px ;     text-align : center:   } #Paragraph {  background-color : lightblue ;     color : black ;     padding : 40px ; }   .city {     background-color : tomato ;     color : white ;     padding : 10px ; } < /style > <!-- A unique element --> < h1 id ="myHeader" > My Cities < /h1 > <!-- Multiple similar elements --> < h2 id ="paragraph" > London < /h2 > < p > Lond...

XHTML/ CSS - Styling Using Classes

Once again there is another way to style elements. We can create a class for an element and apply that class to other elements equally. Here's an example: < style > .city {     background-color : tomato ;     color : white ;     padding : 10px ; } < /style > < h2 class ="city" > London < /h2 > < p > London is the capital of England. < /p > < h2 class ="city" > Paris < /h2 > < p > Paris is the capital of France. < /p > < h2 class ="city" > Tokyo < /h2 > < p > Tokyo is the capital of Japan. < /p > In this example, the class created is city . We have given it some properties and we've added the class to the elements we wanted to.   https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Div

The div element gives you the ability to move elements in certain places on your webpage.  https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Styling More Than One Element

There are multiple ways of doing things in programming, and the main thing is it works. Instead of styling each element one at a time, you can style multiple elements using the same CSS block of code. (i.e. h2 {background-color: red; }, instead h2, h3 {background-color: red}) You can also use the <span> tag within your element to identify only a certain part that you want changed. <p> Hello this is a <span> paragraph </span> and only the word paragraph is changed. </p> By creating a  span {} element in the CSS code you can change the <span> element while leaving the rest of the paragraph untouched. https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Styling Unordered Lists

Again, you can style everything, lists are no exception. Some of the properties you can change are: List style CSS Property Description list-style Sets all the properties for a list in one declaration list-style-image Specifies an image as the list-item marker list-style-position Specifies the position of the list-item markers (bullet points) list-style-type Specifies the type of list-item marker You can style certain elements with images from the internet. (i.e. list-style-image: url(image.png); https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Styling Tables

Just like links, you can style a table with some interesting CSS properties. If you want to style individual parts of a table you can, just be sure to specify what element you are styling in your CSS code.  https://developer.mozilla.org/en-US/docs/Learn/CSS/Styling_boxes/Styling_tables https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Styling Link

Links are dynamic things on a webpage. They have many different states. one, where the link has not been clicked, one where the link has been clicked, hovering over the link, etc.    /* unvisited link */ a:link {     color : red ; } /* visited link */ a:visited {     color : green ; } /* mouse over link */ a:hover {     color : hotpink ; } /* selected link */ a:active {     color : blue ; https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Width/ Height

Width and height are two properties that can be changed to make an element fixed. Property Description height Sets the height of an element max-height Sets the maximum height of an element max-width Sets the maximum width of an element min-height Sets the minimum height of an element min-width Sets the minimum width of an element width Sets the width of an element https://www.youtube.com/watch?v=veKHw125UJs&index=23&list=PLC1322B5A0180C946

XHTML/ CSS - Margin

Margin is the space around an element. There is default margins, but you can move elements around and in relation to each other using margin elements. Definition and Usage The margin property sets the margins for an element, and is a shorthand property for the following properties: margin-top margin-right margin-bottom margin-left If the margin property has four values: margin: 10px 5px 15px 20px; top margin is 10px right margin is 5px bottom margin is 15px left margin is 20px If the margin property has three values: margin: 10px 5px 15px; top margin is 10px right and left margins are 5px bottom margin is 15px If the margin property has two values: margin: 10px 5px; top and bottom margins are 10px right and left margins are 5px If the margin property has one value: margin: 10px; all four margins are 10px Note: Negative values are allowed. https://www.w3schools.com/cssref/pr_margin.asp https://www.youtube.com/watch?v=veKHw125UJs...

Python 3.4 Command Line Arguments (sys.argv)

You can import many different kinds of modules that can help perform many tasks. You can analyze arguments, and do any type of manipulation on those arguments. You can import math modules, etc: https://docs.python.org/3/py-modindex.html https://www.youtube.com/watch?v=9Os0o3wzS_I

Python 3.4 - Functions

Functions are cool because they let you reuse code. You can update a function and have it apply to all elements of your code. You can use string methods on a function and add to, append, upper, lower, etc the function. Here's an example: def functionName ( ):        suite Functions can be made, but there are many functions already: https://docs.python.org/3/library/functions.html https://www.youtube.com/watch?v=9Os0o3wzS_I

Python 3.4 - While Loops/ Count

Adding the functions of counting and totaling one can create a program that can keep track of certain data and use it to give totals, averages, etc. tip_num = 0 total = 0.0 tip = input ( 'please gimme tips' ) while tip != "" : tip_num += 1 tip_value = float (tip) total += tip_value tip = input ( 'please gimme tips' ) print ( "You received" , t5ip_num , "tips this evening!" ) print ( "your total was" , total) https://www.youtube.com/watch?v=qelrVA3zeMc

Python 3.4 - Exception Handling

Sometimes you may have code that could send an error message. This could happen for many reasons. Including a try block of code can handle these situations. try : f = open ( 'main2.py' ) except Exception : print ( 'sorry' ) It is better if you know what kind of error yo can expect to customize the error message or redirect.  try : print ( "hello" ) except Exception : print ( "hellowwww" ) else : print ( "me too me too" ) finally : print ( "WHo cares!" ) https://www.youtube.com/watch?v=NIWwJbo-9_8

Python 3.4 - Console I/O

Your program most likely will have a input console, on the computer and/or keyboard and an output, etc. The user will use this interface to interact with your program. print ( "Welcome" ) name = input ( "What is your name? " ) print ( "Hello " + name + " Thank you for being here." ) num1 = int ( input ( "What is the number?" )) num2 = int ( input ( "what is the second number?" )) print ( "Those two numbers multiplied together are" , num1 * num2) Getting some inputs can be useful. https://robots.thoughtbot.com/input-output-redirection-in-the-shell https://www.tldp.org/LDP/abs/html/io-redirection.html Raw_input allows the user to put in any type of data and convert it to a string. https://www.youtube.com/watch?v=qsTdaxahTsM

XHTML/ CSS - Border

Oh geez what you can do with borders: https://www.w3schools.com/css/css_border.asp  https://www.youtube.com/watch?v=5NSchEMGW-k&index=22&list=PLC1322B5A0180C946

XHTML/ CSS - Padding

Padding is the space around text. If you were to highlight THIS text with you cursor. You will see the padding. You can increase this or move things around based on this. If the padding property has four values: padding:10px 5px 15px 20px; top padding is 10px right padding is 5px bottom padding is 15px left padding is 20px If the padding property has three values: padding:10px 5px 15px; top padding is 10px right and left padding are 5px bottom padding is 15px If the padding property has two values: padding:10px 5px; top and bottom padding are 10px right and left padding are 5px If the padding property has one value: padding:10px; all four paddings are 10px Note: Negative values are not allowed. source: https://www.w3schools.com/cssref/pr_padding.asp https://www.youtube.com/watch?v=tOkQKpb7CVY&index=21&list=PLC1322B5A0180C946

Python 3.4 - For/ While Loops

You can make your life easier with math! While Loops are used when you want a program to run while a certain condition is true. This is another Boolean operation.  The for function is really helpful when it comes to breaking down a list or doing things that are meant to be worked on. https://www.youtube.com/watch?v=Q3T1yyGQd6o

Python 3.4 - Control Flow Statements (Boolean Operators)

Having a program make choices is the next level of sophistication.  Once you are able to create the framework of a site, then the style of the site, then you are able to make the site make choices and begin to interact with the user. By using simple true false statements one is able to direct the site what to do given certain conditions, etc. https://www.cs.fsu.edu/~myers/c++/notes/control1.html

Python 3.4 - Logical Operators

Logical operators are used to check to see if something is True or False. Python uses the and, or, not operators to determine if a conditional test works or not. These can also be used with while statements to direct the program what to do if a set of conditions are True or False. There are many ways you can check to see if conditions are met or not. https://www.youtube.com/watch?v=a7AOWQ2cq6Y

Python 3.4 - Comparison Operators

If you want to test to see if things are equal to each other you can use the comparison operators. The main operators are: Operator Description Example == If the values of two operands are equal, then the condition becomes true. (a == b) is not true. != If values of two operands are not equal, then condition becomes true. (a != b) is true. <> If values of two operands are not equal, then condition becomes true. (a <> b) is true. This is similar to != operator. > If the value of left operand is greater than the value of right operand, then condition becomes true. (a > b) is not true. < If the value of left operand is less than the value of right operand, then condition becomes true. (a < b) is true. >= If the value of left operand is greater than or equal to the value of right operand, then condition becomes true. (a >= b) is not true. <= If the value of left operand is less than or equal to the value of right ope...

Python 3.4 - Integers vs. Strings

In Python you can create data types but there are different kinds. The two main types are integers, or numbers, and strings, or words. Now a string can be a integer, but it will be treated as a string. (i.e. a = 42 is a integer, but a = '42' is a string, just as a = 'panther' is a string) Notice that the quotations are used to indicate a string. https://www.youtube.com/watch?v=RLpa0vVbY6U

Python 3.4 - Membership and Identity Operators

Membership operators check to see if an object is present. using the in function one can determine if an object exists in a data set. data = "My name is Matt" "name" in data True    You can use is or == to determine if a variable is using the same object reference. You may also use the is not to determine if two variables are using the same object reference. my_list = [ 'john' , 'matt' , 'rick' , 'jehovah' , 'buddha' ] my_list2 = [ 'john' , 'matt' , 'rick' , 'jehovah' , 'buddha' ] if 'dog' in my_list: print ( 'hello' ) else : print ( 'not in the list' ) ## the in operator checks to see if the value dog is in the list. if my_list == my_list2: print ( 'they are the same' ) ## this checks to see if they are the same. /Users/mattfassnacht/PycharmProjects/untitled10/venv/bin/python /Users/mattfassnacht/PycharmProjects/untitle...

Python 3.4 - Collection Data Types

You can organize and collect data and store it in various forms (lists, tuples). You can work with these data collections for various purposes and in various ways. You can append, insert, and do other actions with these data collections. You can gather information from a list. >>> x = ["zebra", 49, -879, "aardvark", 200] >>> x.append("more") >>> x ['zebra', 49, -879, 'aardvark', 200, 'more']

Python 3.4 - Object References

Variables can be created in Python. They can be labelled as anything but do need to have an_underscore if there are more than one word. (i.e. variable_name). The object reference is the value that you assign to the variable (a - the variable is = to the object reference 2, i.e. a = 2) It's important to note that if you only have one object reference than the variable, no matter what it is, if it is equal to another object reference it will be referring to that object reference. https://www.youtube.com/watch?v=z_55F4zSjoA Id-ing a variable will give you it's memory location. It is a way to see if two variable are sharing the same object reference or not.

Python 3.4 - Data Types

There are several types of data that can be stored, created, and used in Python. The four main types of data are numbers, strings, lists, and tuples/ dictionaries. Numbers (int, long, float, complex) - Numbers are data types and there are different types of numbers. Integers are Int and are simple numbers. Long are just long integers, Float are integers with a decimal and complex numbers are integers with an imaginary number. https://www.youtube.com/watch?v=LXjb5vqH-MQ Strings (a string of words or one word that is contained in double or single quotes. three quotes can print multiple lines.) https://www.youtube.com/watch?v=SOjBjD3UJww Lists (Another data type is list. Lists can be very useful and can be manipulated in many ways. A list is indicated with brackets [ ] filled with integers, floats, strings, etc. https://www.youtube.com/watch?v=3-U5sY862Ag Tuples (In Tuples you cannot change the values of the data types. The difference is you use a round bracket () instead ...