Posts

Python 3.4 - Reading/ Writing Files

In python you may have a program or some data that you would like to store. You may have a file or bunch of files that you may need to work with. You can read files and write new files with your programs. By saving or linking to files in the same directory or elsewhere you can do this.  https://www.youtube.com/watch?v=Olq86NN6-Ko https://www.youtube.com/watch?v=Uh2ebFW8OYM

UML - Use Case Diagram

Image
UML stands for unified modeling language. It is used to create a blueprint for a project. A use case diagram is a list of steps needed to reach a goal. Its defines what is required and how those requirements are met. You will narrow down what you have to have. Before you create a use case diagram you need to create a description of the use case diagram. For example the above would look something like this: Use case descriptions includes who the actors are, what the triggers are, and other elements. Beta versions of a project have Shall requirements, should requirements can be done but can be done later. A use case diagram uses stereotypes to represent an element of your system. https://whatis.techtarget.com/definition/use-case-diagram https://www.youtube.com/watch?v=OkC7HKtiZC0

2nd Game.

import random from time import sleep def displayintro (): print ( "It's been a long time fighting." ) sleep( 1 ) print ( "You come to a crossroads." ) sleep( 1 ) print ( "You have two paths you can choose." ) sleep( 1 ) print ( 'One will lead to victory one will lead to dismay.' ) print () def choosepath (): path = "" while path != "1" and path != "2" : path = input ( 'What path do you choose? (1 or 2)' ) return path def checkpath (chosenpath): print ( "You head to down the path." ) sleep( 1 ) print ( "There is a battle ahead." ) correctPath = random.randint( 1 , 2 ) if chosenpath == str (correctPath): print ( "You win the battle and head home!" ) else : print ( "You lost and are forgotten in time." ) playagain = "Yes" while playagain == "Yes"

Django Practice

Oh Django, I understand you sort of. Basically the idea is a one-stop shop to make and develop a website. You are using Python, HTML, and CSS to create the things(apps) you want your website to have. Steps: Getting the necessary programs, software (PyCharm, Django, etc) Setting up your environment and setting up all of the apps. Creating your URLs and Templates. Creating your classes and what they will contain, type of info.

Python Practice

name = 'Greedy' condition = 'special' time = 'all of the time' print ( '{} is {} {}.' .format(name , condition , time)) def calc (x , y , operation): if operation == 'add' : return x + y elif operation == 'sub' : return x - y elif operation == 'mul' : return x * y elif operation == 'div' : return x / y running = calc( 14 , 2 , 'div' ) print (running) running2 = calc( 12 , 2 , 'add' ) print (running2) print (running + running2) xyz = [] names = [ 'Mud' , 'Jebidiyah' , 'Florian' , 'Hans' ] for i in list (names): xyz.append(i) for i in range ( 20 ): xyz.append(i) print (xyz) num_list = [ 10 , 3 , 45 , 65 , 40 , 7 , 6 , 9 , 100 ] def div_five (num): if num % 5 == 0 : return True else : return False # So this is basically saying that fives equals any number in the list that passes the #

Python 3.4 - Pep 8 Style Guide

This is a link to a style guide for Python. It is not mandatory, but if you are looking to see how it might be done this could point you in the right direction. https://www.python.org/dev/peps/pep-0008/?

Python 3.4 - Caesar Cipher

Caesar ciphers take a list of values and rotates through them to give them a different value. The program below takes from the alphabet and creates a cipher of the message. It returns many variations of the cipher then returns the actual message. import string import collections def caesar (rotate_string , number_to_rotate_by): upper = collections.deque(string.ascii_uppercase) lower = collections.deque(string.ascii_lowercase) upper.rotate(number_to_rotate_by) lower.rotate(number_to_rotate_by) upper = '' .join( list (upper)) lower = '' .join( list (lower)) return rotate_string.translate( str .maketrans(string.ascii_uppercase , upper)).translate( str .maketrans(string.ascii_lowercase , lower)) my_string = 'This is the message' my_string2 = caesar(my_string , 1 ) for i in range ( len (string.ascii_uppercase)): print (i , "|" , caesar(my_string2 , i)) /Users/mattfassnacht/PycharmProjects/untitled12/venv/bin/pyt