Notes + Vocabulary for Week 1

Vocabulary:

  • Dynamic code: code that can change.
  • Static texts: unchanging code.
  • String: strings in python are surrounded by either single quotation marks, or double quotation marks.
  • Sequence of code: two or more lines of code form a sequence.

Code:

  • Print(): outputs code, either strings, numbers, or variables.
  • Variables: Variables are containers for storing data values. A variable is created the moment you first assign a value to it.
  • If...else commands: An "if statement" is written by using the if keyword. If statements are used to input if something is to happen, something else will happen. An else statement is if that if does not occur the else statement will occur.

Introducing Python

  • In python, the first code you learn to print out is a hello world message. Example below:
print ("Hello, World!")
  • "Hello, World" is a string and strings are static texts.
  • Static texts are called static texts because they do not change.
  • The print command outputs the message "Hello, World!"
  • An output is the code that is displayed after it is run.
Variables, Inputs, and Outputs

Variable example:

msg = "variable example"
print (msg)
variable example

In this code, the variable is "variable example" and when you input it as the variable name, "msg," the print function outputs the input.

Functions

A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. A function can return data as a result.

  • functions are defined using the def keyword
  • To call a function, use the function name followed by paranthesis

Example:

def my_function():
  print("Hello from a function")

my_function()
Hello from a function
Imports, Selection, and Logical Expressions

In this example I am importing from a library called "os", this library extracts properties from the operating system of my existing system. Python and Jupyter docs requires you to reference imports and definitions above the referencing line of code.

  • Import os, sys obtain functions and variables from running environment
  • Print('Hello, ' + getpass.getuser() + " running " + sys.executable + " on " + sys.platform + "!"), is a concatenated statement that outputs properties from the import

    My example defines a new function "question_with_response", this function returns a value input by the user. This allows the programmer to evaluate the response. The purpose of obtaining the return value is to evaluate if the correct response was given to the question.

    • Response from "question_with_response" is captured in a variable called "rsp"
      • return command in function returns msg input by user
      • assignment to "rsp" is allowed a function is returning a value, names do not need to match (but could)
  • If command is next command in sequence after "rsp" assignment

    • this command contains an expression, rsp == "import" which compare what is typed to the string literal answer
    • an if expression is evaluated for true or false
    • true takes branch of code directly under if
    • false takes branch of code directly under else command
  • The grand finally of this example is calculating the right/total.

    • question = 3 is defined as number of questions
    • correct = 0 is defined as running score
    • correct += 1 is the way to add one to the score, this code is placed in sequence under correct expression evaluation
    • since question and correct are numbers, versus strings, to place them in concatenation in print statements you must inclose them in Python function str() which turns number into string.
    • final print statement is concatenated and formatted to give user and right over wrong

My Python Quiz Example:

import getpass, sys

#create function question_with_response 
def question_with_response(prompt):
    print("Question: " + prompt)
    msg = input()
    return msg

#create variables for questions and number of correct
questions = 6
correct = 0

#create function question_and_answer
def question_and_answer(prompt):
    msg = input()
    return msg

#start quiz by saying hi to user and asking if they are ready to take the test
print('Hey, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions. Are you ready to take a fun test!? :D Respond with 'ok' to continue.")
question_and_answer("Are you ready to take a fun test!?")

#ask first question
rsp = question_with_response("What command is used to include other functions that are developed?")

#run command if correct add point
if rsp == "import":
    print(rsp + " is correct!")
    correct += 1
# run else command if incorrect, no point
else:
    print(rsp + " is incorrect!")

#ask second question
rsp = question_with_response("What command in this example is used to evaluate a response?")

#run command if correct add point
if rsp == "if":
    print(rsp + " is correct!")
    correct += 1
#run else command if incorrect, no point
else:
    print(rsp + " is incorrect!")

#ask third question
rsp = question_with_response("Each 'if' command contains an '_________' to determine a true or false condition?")

#run command if correct add point
if rsp == "expression":
    print(rsp + " is correct!")
    correct += 1
# run else command if incorrect, no point
else:
    print(rsp + " is incorrect!")
    
#Introduce what type of questions will be next
print ("The next 3 set of questions will be True or False. Please respond with either capital 'True' or 'False' Good luck and good job so far!")
    
#ask fourth question
rsp = question_with_response("True or False: The print command outputs the paramater to the terminal.")

#run command if correct add point
if rsp == "True":
    print(rsp + " is correct!")
    correct += 1
#run else command if incorrect, no point
else:
    print(rsp + " is incorrect!")
    
#ask fifth question
rsp = question_with_response("True or False: Output in Jupyter is below the code cell.")

#run command if correct add point
if rsp == "True":
    print(rsp + " is correct!")
    correct += 1
#run else command if incorrect, no point
else:
    print(rsp + " is incorrect!")
    
#ask sixth question
rsp = question_with_response("True or False: Static text changes.")

#run command if correct add point
if rsp == "False":
    print(rsp + " is correct!")
    correct += 1
#run else command if incorrect, no point
else:
    print(rsp + " is incorrect!")

# tell user their score
print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))
Hey, najafonseca running /usr/local/bin/python3
You will be asked 6 questions. Are you ready to take a fun test!? :D Respond with 'ok' to continue.
Question: What command is used to include other functions that are developed?
import is correct!
Question: What command in this example is used to evaluate a response?
if is correct!
Question: Each 'if' command contains an '_________' to determine a true or false condition?
expression is correct!
The next 3 set of questions will be True or False. Please respond with either capital 'True' or 'False' Good luck and good job so far!
Question: True or False: The print command outputs the paramater to the terminal.
True is correct!
Question: True or False: Output in Jupyter is below the code cell.
True is correct!
Question: True or False: Static text changes.
False is correct!
najafonseca you scored 6/6

Notes and Vocabulary for Week 2

Lists and Dictionaries

Lists and Dictionaries are used to store or collect information.

  • List is used to collect many instances of a pattern
  • Dictionary is used to define data patterns.
  • Iteration is often used to process through lists.

  • A lists data type is: class 'list'

  • '.append(expression)' allows you to add to the list

A list of dictionaries will be the output of the code below:

InfoDb = []

# InfoDB is a data structure with expected Keys and Values

# Append to List a Dictionary of key/values related to a person and cars
InfoDb.append({
    "FirstName": "Naja",
    "LastName": "Fonseca",
    "DOB": "September 20, 2007",
    "Residence": "San Diego",
    "Hobbies": "Running and Coloring",
})

# Print the data structure
print(InfoDb)
[{'FirstName': 'Naja', 'LastName': 'Fonseca', 'DOB': 'September 20, 2007', 'Residence': 'San Diego', 'Hobbies': 'Running and Coloring'}]

Managing data in Lists and Dictionaries is for the convenience of passing the data across the internet, to applications, or preparing it to be stored into a database. It is a great way to exchange data between programs and programmers. Exchange of data between programs includes the data type the method/function and the format of the data type. These concepts are key to learning how to write functions, receive, and return data. This process is often referred to as an Application Programming Interface (API).

def print_data(d_rec):
    print(d_rec["FirstName"], d_rec["LastName"])  # using comma puts space between values
    print("\t", "Residence:", d_rec["Residence"]) # \t is a tab indent
    print("\t", "Birth Day:", d_rec["DOB"])
    print(", ".join(d_rec["Hobbies"]))  # join allows printing a string list with separator
    print()


# for loop algorithm iterates on length of InfoDb
def for_loop():
    print("For loop output\n")
    for record in InfoDb:
        print_data(record)

for_loop()
For loop output

Naja Fonseca
	 Residence: San Diego
	 Birth Day: September 20, 2007
R, u, n, n, i, n, g,  , a, n, d,  , C, o, l, o, r, i, n, g

The print_data() function receives a parameter called "d_rec" short for dictionary record. It then references different keys within [] square brackets. The for_loop() function uses an enhanced for loop that pull record by record out of InfoDb until the list is empty. Each time through the loop it call print_data(record), which passes the dictionary record to that function. I activated my function with the call to the defined function for_loop(). Functions are defined, not activated until they are called. By placing for_loop() at the left margin the function is activated.

Agile Methodology

7 Important Transferable Skills Notes

1. Creativity

Creativity is mostly seen as how you approach tasks and solve problems. If you solve even the smallest problem, you’ve demonstrated creativity. This skill scales up: Big problems are enlarged small problems; small problems scaled up are big problems.

Creativity includes:

  • Conceptualize problems and solutions
  • Display foresight
  • Make connections
  • Make intelligent inferences
  • Synthesize ideas and data

2. Critical Thinking

Solving complex or abstract problems requires critical thinking.

  • The ability to take a step back and look at things more critically and say ‘Where might we have to have gotten this wrong?’ or ‘How might we be able to improve this?’ is critical thinking. If you can articulate this skill you will stand out!
  • Critical thinkers head off problems before they arise. And if they do surface, they take them head-on.

Be a critical thinker and you'll be able to face any problem!

3. Communication

Effective communication is VERY important. Communication is KEY! Without effective communication, your team is doomed and so is everyone else who works with you.

Important communication skills include:

  • Verbal: speakinging clearly and sometimes being repetitive.
  • Listening: learning to be quiet and listen with your eyes and ears.
  • Writing: Taking notes are good writing skills.
  • Technological: Being able to work through technical problems as a team and discussing them with teammates.

4. Collaboration and thorough Leadership

Leadership skills generally encompass communication, problem-solving and managing conflict, relationship building and being able to get people on your team on board with a mission or project. Leaders should be inclusive, kind, and make good decisions that will benefit their team.

Leadership skills:

  • Delegating responsibility
  • Demonstrating effective time management
  • Initiating new ideas
  • Major decision-making
  • Managing conflict
  • Managing groups
  • Multitasking
  • Teaching and mentoring

5. Collaboration through Teamwork

Teammwork is very important to be able to work well with others. Trust is the major difference between working alone versus working in groups. And trust can be hard: Some people are skeptical by nature or want to work through an entire project lifecycle solo. But placing trust in an active, dynamic team provides more than just project completion. Teamwork — a sense of community — elevates spirits and improves productivity.

Working as a Team includes:

  • Accepting responsibility
  • Making and implementing decisions
  • Managing time wisely
  • Meeting both short- and long-term goals
  • Organizing
  • Setting and meeting deadlines

6. Researching

Every step in technology made requires research. Research is a key part of the lifecycle: changing plans, fluctuating results, and roadblocks require research before anyone can take action. Interacting with your teammates and collaborating also counts as research.

Researching includes:

  • Analyzing information
  • Brainstorming solutions
  • Delineating needs and requirements
  • Extracting information from data
  • Gathering information
  • Forecasting possible roadblocks
  • Setting goals
  • Solving problems

7. Technical

Try to stay current with the many technical advancements on your project. This includes collaborating with your teammates to make sure you're all caught up and on the same page as them. Be knowledgeable and speak to the technical things that you are learning.

Technical skills include:

  • Being easy to work with
  • Having the ability to learn quickly
  • Being excited/happy to learn
  • Failing and Fixing
  • Being willing to try new things
  • Willing to open new doors in case of a drastic oversight