Homework: Returning Values in JS
Getting Values Back From a Function Next let’s practice getting data back from a function with a series of functions that are all called from the main part of the program. Create a program called returning.html- we will use internal JavaScript on this one. Do one function at a time – add code to the…
Read MoreHomework: Passing Values Functions in JS
Passing Values to Functions Let’s practice passing data to functions with a series of functions that are all called from the main part of the program. Create a program called passing.html- we will use internal JavaScript on this one. Do one function at a time – add code to the main part if you need…
Read MoreBoolean Operators
Now, we know how to check to see if a single condition is valid or not. But, often you are checking to see if multiple conditions are valid. For example, if it is Sunday and the weather is nice you can go swimming. We use Boolean Operators to evaluate more than one condition. Operator Description…
Read MoreHomework: Returning Data
Let’s practice passing data to functions with a series of functions that are all called from the main part of the program. Create a program called returning.py. Do one function at a time – add code to the main part if you need to ask for any variables, create the function in the top part…
Read MoreHomework: Passing Data
Let’s practice passing data to functions with a series of functions that are all called from the main part of the program. Create a program called passing.py. Do one function at a time – add code to the main part if you need to ask for any variables, create the function in the top part…
Read MoreHomework: First Function
Create a new file called functions1.py and add the following capabilities to it – remember to have your functions in the top part of your file and the main part of the code at the bottom. Part 1: Say Hello! Create a simple program to give a greeting…”What’s up?“, “Corona Who?“, or something of your…
Read MoreFunctions: Variable Scope
When you use variables in functions and with functions, you need to understand how scope works. Or even what it is! Scope defines where a variable is visible or can be used. There are two main types: global and local. Global: variables are declared in the main part of the program and can be used…
Read MorePassing Data
Passing Data to Functions You can pass data to functions through parameters Let’s add on to our function so that we can say hello and greet you by name. Here’s our updated function : def hello(first_name): print(“Hello,”, first_name,”!”) And you would call the function like this: first_name = input(“What’s your name?”) hello(first_name) As shown in…
Read MorePassing Data to Functions
One of the great strengths of functions, is the ability to pass data to the function, for the function to perform some logic or manipulation on that data and for the function then to return a value back to the main program. This allows code to be reused over and over again. Say you were…
Read MoreMore for Loops
Using for Loops with Strings & Lists A great place to use a for loop is when you are processing strings and lists. You can use the loop to easily go through each value in the string or list storing each character or each list item in the index variable. Let’s take a look at…
Read More