Sie sind auf Seite 1von 2

Lab 4: Modules and APIs

In this lab you are going to experiment around with Modules and APIs. This is consisting of a couple
small things we covered in class. If you are unable to understand some of the content, please contact
me ASAP.

Please read the instruction carefully and submit it exactly as instructed! You are required to resubmit it
if it is done wrong.

Everything including this written part and your programs are send as a zip file.

Last Section on Python:

1. Please describe the purpose of a list?


2. What is an iterator? Show examples.
3. What are the numbers that are assigned to each item on the list?
4. If there was a list, how can you call a specific index within that list? Call for the intended index
for the following:
a. List1 = [‘Cake’, ‘Brownies’, ‘Cookies’, ‘Pies’] (Call for Cookies)
b. List2 = [‘Apples’, ’Pears’, ’Oranges’, ‘Bananas’] (Call for Apples)
5. Say you have a list value like this:
spam = ['apples', 'bananas', 'tofu', 'cats']

Create a function that list a value and returns all the items separated by a comma and a space.

Please put this function into a program file called spam.py.

6. Create a file called Cards.py and try out the deck program we discussed in class.

APIs:

1. Please create a script/program that would do the following Linux commands:


a. Display ‘ifconfig’
b. Pings a specific website a specific amount of times. (Linux Command for ping is ping)
c. Nslookup a website address (Nslookup looks up information about the website)

2. PYOWM: Python Open Weather Module


a. On Linux you are required to do some pre-work before getting this program to work.
b. First go to Linux and run the following command: pip install pyowm
c. Now create a program called weather.py and follow the usage page for reference on
https://github.com/csparpa/pyowm or
https://github.com/csparpa/pyowm/blob/master/pyowm/docs/usage-examples.md

Use the following API key: 8b82950663d455fbc86cf368fa4812a6


(Please remember not to spam since other students would not be able to use the API.)
d. Next do the following:
i. Ask for user input for City and Country
ii. Displays the geographic coordinates for the city/country.
iii. Display the current weather using the user’s info. (This includes the
temperature in F or C.)
iv. Tell the user if the weather is windy, snowing, raining, or cloudy.
v. Display the forecast for the next five days of the user’s city/country.
vi. Display the humidity and pressure and sea level.

Das könnte Ihnen auch gefallen