Week 2 CODE!!!!
STRUGGLE STREET with uploading to git hub and running tests but working through the extraordinarily large volumes of homework — who said I ever wanted a life!
Holy Wars was discussed as our assignment
The project is about understanding how deep arguments go while not having to actually know the techniques. I will need to go “super deep” into it and read all the forums etc. The idea is to argue and present both viewpoints without class knowing which one I agree with until the very end.
There will be 21 slides — 1 with my name and 20 with content.
15 seconds for each slide so I need to be prepared in what I will be saying for each one.
My Operating system — windows — ubuntu which forks — Python packages and atom packages (atom is a text editor).
VM terminal — is a way of speaking to my computer instead of clicking folders.
Basic commands (as I am so green on a PC or computer)
ctrl z = undo
ctrl y = redo
ctrl + shift = switch screens
Commands for terminal
ls = list
cd = change directory
.. = up a directory
. = current directory
../../ = goes back two parent directories
pwd = print working directories — list of all folders
.append = puts it on the end of a list
alt + F3 = while typing changes all to the same word. Highlights word so you can change whole document in one go
Shift + ctrl (+ arrow sideways) = highlights whole word
ctrl + (arrow sideways)= jumps whole word
shift + alt (arrow up or down) = extends cursor
Pull Requests — Ask master idea/recipe/file to take your changes on.
Linting — is about making code readable to other people. Programs are written for people and machines just happen to execute them.
Homework week 2
Exercise 1 was all about fixing the Linting of the code. I went through and did all of this and followed the instructions to push it to github (this is something I really find difficult to check if I’ve done correctly and I know it matters for HW submission ). Now when I run my tests though the exercise 1 fails its test? I dont know know why?
Exercise 2 was the same. We had to read all of the errors and fix them one by one. Again struggling to work out the running of tests and uploading to github. I have completed both of these but still really confused off ‘pushing’ them?
Exercise 3 WOW thank god Ben made some videos. I can see he uses python1 to play around with the meaning of the code and I can understand the logic behind how he is solving them. I feel lost though, maybe its because I don’t know python meanings yet? im still in the process of finishing this one when he does more videos.
Running a test for Home Work
Need to be in Code1161base folder
To Commit for Homework
Need to save changes in Atom
git add week2/exercise1.py
git commit -m “pass all linter test (I can write what I want here)”
- After this the exercise I push wont be in the status lists (why? — I don't really understand)
I then started CODE SCHOOL
>>> = entering a code
— > (arrow) = is the outcome or result
int = whole number
float = decimal number
Help = displays help menu
- label and access info
- No spaces or numbers to start
- helps you understand what your trying to do
- Use under_scores for spaces
- Sequence of characters
- “surround by quotes” or ‘single quotes’ but be consistent
- eg ‘Hello World’
print() = outputs script files
# = is a comment to describe what you are doing but doesn’t get run
\n = new line
\t = indent
#My favourite movies
movie1 = hotshots
movie2 = spaceballs
movie1 = \n\thotshots
movie2 = \n\tspaceballs
print(‘My favourite movies’ , movie1, movie2)
= My favourite movies
(indented but not working on medium) hotshots
(indented but not working on medium) Spaceballs
Indexes — from strings
- always start from 0
greeting = “Hello world”
>>> greeting = ‘H’
len = length of indexes
eg print( len(greeting))
Slices — Gives portions of words/code so you don’t have to pull individual indexes.
Example: word = python
this says we want letters starting at 2 and ending before 5
word[:2] = py (leaves start out so it automatically starts at the beginning)
word[4:] = on (leave end out and it automatically runs to the end)
Formula = Index of first character you want + (index of last character you want +1)
Index at half way points — Use length // (divided by, but use two/ so you get a whole number — int)
word1 = ‘Good’
half1 = len(word1)//2
end1 = word1[half1:]
half2 = len(word2)//2
end2 = word2[half2:]
>>> od ning
Conditionals — act as questions and give true or false answers (see later knights example)
< less than
<= less than equal to
== equal to
> greater than
>= greater than equal to
!= not equal to
day = input(‘enter the day of the week’)
- this saves the users choice and allows a user to input into the code (see later example)
Nested Conditions — These ask a follow up question
EXAMPLE FOR CONDITIONS, NESTED CONDITION AND INPUTS
num_knights = int(input(‘Enter number of knights’))
day = input(‘Enter day of the week’)
enemy = input(‘Enter enemy type’)
if enemy == ‘Killer bunny’
(indented) print(‘Holy hand grenade)’
(indented) #original battle rules
(indented) if num_knights < 3 or day == ‘Monday’:
(indented)if num_knights >= 10 and day = ‘Wednesday’:
(indented)(indented) print(‘Trojan rabbit’)
The video tutorials were awesome and SLOW in helping me understand what was going on in these examples!!!!