Teaching myself Python Day 9

Words
72
Reading
1 min
Listen
Play
7y

pythonpowered.png

Day 9, I have continued viewing the:
Programming with Python | Python for Beginners
https://www.youtube.com/playlist?list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6
videos and have learned more about loops and even started learning about calling an API from Python. I was quite surprised to find out how easy it was to call an API to get the current price of STEEM.

Here is the code from today's learning:

from datetime import datetime, timedelta
from pycoingecko import CoinGeckoAPI
cg = CoinGeckoAPI()
import time
import logging
log = logging.getLogger("pylearn-day9")
logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s %(levelname)s %(message)s',
                    filename='pylearn.log',
                    filemode='a')
log.info("Starting program")

utc_date = datetime.utcnow()
print('pylearn-day9')
print('UTC ' + str(utc_date))
#testing assigning different data types into list
test_list = ['string', 7]
print()
print('Printing list = ' + str(test_list))
print()
print('Printing an item from list - ' + str(test_list[1]))
print()
#Iterating thru list with for loop
for item in test_list:
    print('Printing an item from list - ' + str(item))
print()
index = 0
#Iterating thru list in while loop
while index < len(test_list):
    print('Printing an item from list - ' + str(index))
    index = index + 1
print()
print(cg.get_price(ids='steem', vs_currencies='usd'))
print()

And here is a screen capture of the output from the program:

Screenshot from 2019-12-16 16-48-48.png

Teaching myself Python Day 9 | Ecency