Functions are programming constructs that helps us package common operations. In addition they make our code that much more readable.
They have a format that looks like this:
def first_function():
pass
output = first_function()Functions are programming constructs that helps us package common operations. In addition they make our code that much more readable.
They have a format that looks like this:
def first_function():
pass
output = first_function()##Step 1
In programming, recurrence happens a lot. In fact it can be said that the entire essence of programming is to automate recurring steps.
Suppose for example we needed to have python print out a list of all numbers between 1-10 how would we do it?
Lets first create the folder for the lesson. From the terminal type in
mkdir 5lesson
In previous entries we have been mostly manipulating strings and numbers. The numbers have had to be hard set inside the file.
eg
area = 5 * 3
print(area)This is obviously useful for learning, but in real world programming. You must admit input from the users.
##Step 1
Open up your workspace on c9.io and activate the bash.
Type in
python3
We have looked at how to create an API. In this challenge we shall be looking at how to consume one.
Based on the test data here
https://jsonplaceholder.typicode.com/posts
Create a system that displays this information in a table.
Notes:
##What is an API
In previous classes, we have been using forms and tables to input and display data respectively.
This works well for pure web applications. When we want to open up our application for integration, then we need an API (Application Programming Interface).
An API allows programmatic access to your application. This means that integrations such as:
Laravel at the moment is at version 5.3. In class we have been using Laravel 5.2.
This is a major upgrade:
##Step 1
Once you have your app in production. Data is guaranteed to start flowing in. As such you can no longer show all the information from a particular table at once.
Laravel provides an out of the box solution for pagination.
##Step 1:
Ensure you have enough student records so that they can be paginated. That is have at least 20 records in your students database.
You can do this by adding records using your form.