Posts

Showing posts from June, 2018

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/?