---
tags: gps
---
# GPS Skills Course Series - Python (2023Winter)
**Course Details**
Dates: January 10th, 2023 - January 26th, 2023
Days: Tues/Thurs
Time: 2-3:30pm
**Course Agenda:**
(Github page)
**Software Installation:**
*Refer to Canvas course software download files.
**Lesson Data (download)**
*Refer to Canvas course data download files.
## NOTES:
A copy of the instructor live session notes will be uploaded in canvase at the end of session lesson.
Jupyterlab will be used for the lessons
[m] Markdown cell = notes
[#]also works in code cell for notes
[b] = add cell below [a] is above
[r]Raw cells cannot have text edits
https://www.markdownguide.org/getting-started/
https://www.markdownguide.org/basic-syntax/
## Session 1
### Name (Last, First) / Email
Doe, John / jdoe@ucsd.edu (example)
Chow, Viola / v1chow@ucsd.edu
Yang, Marcia / mxyang@ucsd.edu
Lascano,Dayra / dlascano@ucsd.edu
Li, Bingru / bil005@ucsd.edu
Li, Weitong / wel056@ucsd.edu
Tang, Wei-Hsin wet001@ucsd.edu
Cai, Weiyan / w1cai@ucsd.edu
He,Taylor/ zhh043@ucsd.edu
Lian, Ann / alian@ucsd.edu
Cen, Jasper Junjie / j1cen@ucsd.edu
Fragoso, Alberto / afragoso@ucsd.edu
Suematsu, Tomoyuki / tsuematsu@ucsd.edu
Ye,Yuan/ yeyuan@ucsd.edu
Himanshu Pykurel Himanshu/ hpykurel@ucsd.edu
Xiaoran Li, xil206@ucsd.edu
Yamada, Sohei / syamada@ucsd.edu
Yamakawa, Daisuke / dayamakawa@ucsd.edu
Dukhnovskii, Fedor / fdukhnovskii@ucsd.edu
Molina, Angela/ armolina@ucsd.edu
Roshdieh Altamimi/rraltamimi@ucsd.edu
Kato, Hiroaki / h2kato@ucsd.edu
Edwards, Lauryn/ltedward@ucsd.edu
Xu, Junhui/ jux008@ucsd.edu
Mason-Lucas, Olivia / omasonlucas@ucsd.edu
Phrasavath, Bonaly / bphrasav@ucsd.edu
Junyi Hua/ juhua@ucsd.edu
Paula jaramillo / pjaramillo@ucsd.edu
Orosz, Stephanie/ sorosz@ucsd.edu
Berman-Schneider, Ray /hbermanschneider@ucsd.edu
Cuevas, Christopher / ccuevas@ucsd.edu
Nakamura, Masaki / m1nakamura@ucsd.edu
Murashima, Mizuki/ murashima@ucsd.edu
Ahluwalia, Gurkriti / gahluwalia@ucsd.edu
Gabriela Quintanilla/gquintanilla@ucsd.edu
Leung, Taysia (T/t3leung@ucsd.edu
Ilaria, Simmen / isimmen@ucsd.edu
Yamashita, Daichi / dyamashita@ucsd.edu
Fang, Zhuohan / zhf003@ucsd.edu
CHi, Zhiyuan / z1chi@ucsd.edu
Chen, Wenxin / wec027@ucsd.edu
Groper, Danielle / dgroper@ucsd.edu
Xiang, Ruixuan / r1xiang@ucsd.edu
Coyle, Jackson / jacoyle@ucsd.edu
Wang, Xuran / xuw028@ucsd.edu
Guo, Yuxin / yug041@ucsd.edu
Ito, Yoshi/ yoito@ucsd.edu
Duan,Yihan/ yid024@ucsd.edu
Yin, Qing / qiyin@ucsd.edu
Artan, Warsan / wartan@ucsd.edu
Yamashita, Aoi / aoyamashita@ucsd.edu
Bo,Yutong/yubo@ucsd.edu
Tan, Jingyi / j3tan@ucsd.edu
Quintanilla, Gabriela / gquintanilla@ucsd.edu
Kato, Hiroaki / h2kato@ucsd.edu
Murashima, Mizuki / mmurashima@ucsd.edu
Zhuohan, Fang/zhf003@ucsd.edu
## Session 1 Questions:
Please enter any questions not answered during live session here:
1.
### End Session 1
## Session 2
### Name (Last, First) / Email
Doe, John / jdoe@ucsd.edu (example)
Ito, Yoshi/ yoito@ucsd.edu
Yin, Qing / qiyin@ucsd.edu
Lascano, Dayra / dlascano@ucsd.edu
Coyle, Jackson / jacoyle@ucsd.edu
Groper, Danielle / dgroper@ucsd.edu
Cuevas, Christopher / ccuevas@ucsd.edu
Phrasavath, Bonaly / bphrasav@ucsd.edu
Tan, Jingyi / j3tan@ucsd.edu
Chen, Wenxin / wec027@ucsd.edu
Duan, Yihan / yid024@ucsd.edu
Yamakawa, Daisuke / dayamakawa@ucsd.edu
Yamashita, Daichi / dyamashita@ucsd.edu
Nakamura, Masaki / m1nakamura@ucsd.edu
Zhiyuan Chi / z1chi@ucsd.edu
Yamada, Sohei / syamada@ucsd.edu
Pykurel,Himanshu / hpykurel@ucsd.edu
Xiaoran Li/ xil206@ucsd.edu
Suematsu Tomoyuki/ tsuematsu@ucsd.edu
Quintanilla, Gabriela / gquintanilla
Berman-Schneider, Ray / hbermanschneider@ucsd.edu
Edwards, Lauryn/ltedward@ucsd.edu
Leung Taysia/t3leung@ucsd.edu
Romstadt, Lisa / lromstadt@ucsd.edu
Fragoso, Alberto / afragoso@ucsd.edu
Lian, Ann / alian@ucsd.edu
Artan, Warsan / wartan@ucsd.edu
Bingru, Li / bil005@ucsd.edu
Paula Jaramillo/ pjaramillo@ucsd.edu
Nogueda, Lesley/lnogueda@ucsd.edu
Weitong Li / wel056@ucsd.edu
Orosz, Stephanie/ sorosz@ucsd.edu
Junhui Xu / jux008@ucsd.edu
Xiang, Ruixuan / r1xiang@ucsd.edu
Murashima, Mizuki / mmurashima@ucsd.edu
Ahluwalia, Gurkriti / gahluwalia@ucsd.edu
## Session 2 Questions:
Please enter any questions not answered during live session here:
1.
### End Session 2
## Session 3
### Name (Last, First) / Email
Doe, John / jdoe@ucsd.edu (example)
Zhiyuan Chi / z1chi@ucsd.edu
Phrasavath, Bonaly / bphrasavath@ucsd.edu
Yamada, Sohei / syamada@ucsd.edu
Dayra Lascano / dlascano@ucsd.edu
Ye Yuan/ yeyuan@ucsd.edu
Fragoso, Alberto / afragoso@ucsd.edu
Nakamura, Masaki / m1nakamura@ucsd.edu
Wenxin Chen/wec027@ucsd.edu
Romstadt, Lisa / lromstadt@ucsd.edu
Xiaoran Li/xil206@ucsd.edu
Junyi Hua/juhua@ucsd.edu
Berman-Schneider, Ray /hbermanschneider@ucsd.edu
Wei-Hsin Tang/wet001@ucsd.edu
Pykurel, Himanshu / hpykurel@ucsd.edu
Artan, Warsan / wartan@ucsd.edu
Zhuohan, Fang / zhf003@ucsd.edu
leung,taysia/t3leung@ucsd.edu
Orosz, Stephanie/ sorosz@ucsd.edu
Junhui Xu / jux008@ucsd.edu
Weitong Li/ wel056@ucsd.edu
Lian, Ann / alian@ucsd.edu
Suematsu Tomoyuki/ tsuematsu@ucsd.edu
Bingru, Li / bil005@ucsd.edu
Molina, Angela/ armolina@ucsd.edu
Lesley Nogueda/ lnogueda@ucsd.edu
Cuevas, Christopher / ccuevas@ucsd.edu
Edwards, Lauryn/ltedward@ucsd.edu
Altamimi, Roshdieh/rraltamim@ucsd.edu
Quintanilla, Gabriela / gquint
Simmen, Ilaria / isimmen@ucsd.e
Yamakawa, Daisuke / dayamakawa@ucsd.edu
Dukhnovskii, Fedor / fdukhnovskii@ucsd.edu
Tan, Jingyi / j3tan@ucsd.edu
Yamashita, Daichi / dyamashita@ucsd.edu
Groper, Danielle / dgroper@ucsd.edu
Coyle, Jackson / jacoyle@ucsd.edu
Ito, Yoshi/ yoito@ucsd.edu
Chen, Wenxin/ wec027@ucsd.edu
Duan, Yihan/ yid024@ucsd.edu
Xiang, Ruixuan / r1xiang@ucsd.edu
Murashima, Mizuki / mmurashima@ucsd.edu
Lian, Ann / alian@ucsd.edu
Xu, Junhui /
jux008@ucsd.edu
Ahluwalia, Gurkriti / gahluwalia@ucsd.edu
# NOTES
using Python libraries
### Import `math` library
```python=
import math as m
import math as np #assign an alias short form name using `as`
math.pi #calculates pi
math.cos(math.pi)
print('cos(pi) is equal to: ', math.cos(math.pi)
```
### print output
```python=
print('pi is equal to: ', math.pi)
```
#### How do you learn more about a specific library?
```python=
help(math) #help functino to find help about a library or function
```
#### How do you shorten programs by importing specific items from a library?
```python=
from math import cos, pi
```
Challenge 1
using the function:
```python=
help(math)
```
identify a function fromt the math library, which you can use to calculate square or cube roots, and/or power (e.g. 3 to the power of 4)?
one answer:
pow(x,y,/)
```python=
from math import cos, pi pow
pow(2, 1/2, /) #incorrect format returns invalid syntax
pow(2, 1/2) # correct format
print('square root of 2: 1, pow(2,1/2))
```
what library is sqrt2 in?
```python=
from math import pow, sqrt # need to specifcy sqrt function from the math library
```
```python=
import random #generate random numbers
```
```python=
from random import randrange
bases = 'ACTTGCTTGAC #defined string variable
random_index = randrange(len(bases)) #saving a random index value between 0 -11 based on length of bases string
print(len(bases)) #print out the length of the string
print(random_index) #printing out the random index value
print(bases[random_index]) #
```
```python=
```
## Session 3 Questions:
Please enter any questions not answered during live session here:
1.
### End Session 3
## Session 4
### Name (Last, First) / Email
Doe, John / jdoe@ucsd.edu (example)
Yamashita, Daichi / dyamashita@ucsd.edu
Ito, Yoshi/ yoito@ucsd.edu
Tan, Jingyi/ j3tan@ucsd.edu
Cuevas, Christopher / ccuevas@ucsd.edu
Groper, Danielle / dgroper@ucsd.edu
Coyle, Jackson / jacoyle@ucsd.edu
Dayra Lascano / dlascano@ucsd.edu
Duan, Yihan/ yid024@ucsd.edu
Phrasavath, Bonaly / bphrasavath@ucsd.edu
Yamakawa, Daisuke / dayamakawa@ucsd.edu
Weitong Li / wel056@ucsd.edu
Chen, Wenxin / wec027@ucsd.edu
Zhiyuan, Chi / z1chi@ucsd.edu
Artan, Warsan / wartan@ucsd.edu
Xiang, Ruixuan / r1xiang@ucsd.edu
Nakamura, Masaki / m1nakamura@ucsd.edu
Yamada, Sohei / syamada@ucsd.edu
Zhuohan, Fang / zhf003@ucsd.edu
Stephanie Orosz / sorosz@ucsd.edu
Paula jaramillo
Pykurel, Himanshu / hpykurel@ucsd.edu
Junyi Hua/juhua@ucsd.edu
Suematsu, Tomoyuki / tsuematsu@ucsd.edu
Chen, Wenxin/wec027@ucsd.edu
Kimothy, Wong / cwwong@ucsd.edu
Murashima, Mizuki / mmurashima@ucsd.edu
Nogueda, Lesley/ lnogueda@ucsd.edu
Romstadt, Lisa / llromstadt@ucsd.edu
Lian, Ann / alian@ucsd.edu
Ahluwalia, Gurkriti / gahluwalia@ucsd.edu
leung,taysia /t3leung@ucsd.edu (watched video)
## Session 4 Questions:
Please enter any questions not answered during live session here:
1.
### End Day 4
## Session 5
### Name (Last, First) / Email
Doe, John / jdoe@ucsd.edu (example)
Phrasavath, Bonaly / bphrasav@ucsd.edu
Edwards, Lauryn/ltedward@ucsd.edu
Berman-Schneider,Ray/ hbermanschneider@ucsd.edu
Fragoso, Alberto / afragoso@ucsd.edu
Nakamura, Masaki / m1nakamura@ucsd.edu
Yamada, Sohei / syamada@ucsd.edu
Lascano, Dayra / dlascano@ucsd.edu
Weitong Li / wel056@ucsd.edu
Orosz, Stephanie / sorosz@ucsd.edu
Junyi Hua/@u
Cuevas, Christopher / ccuevas@ucsd.edu
Ye Yuan/ yeyuan@ucsd.edu
Molina, Angela/ armolina@ucsd.edu
Tang, Wei-Hsin/ wet001@ucsd.edu
Artan, Warsan / wartan@ucsd.edu
Pykurel, Himanshu / hpykurel@ucsd.edu
Xiaoran Li/xil206
Ito, Yoshi/ yoito@ucsd.edu
Suematsu, Tomoyuki / tsuematsu@ucsd.edu
Nogueda, Lesley/ lnogueda@ucsd.edu
Kato, Hiroaki / h2kato@ucsd.edu
Murashima, Mizuki / mmurashima@ucsd.edu
Yamakawa, Daisuke / dayamakawa@ucsd.edu
Zhuohan, Fang / zhf003@ucsd.edu
Lian, Ann / alian@ucsd.edu
Ahluwalia, Gurkriti / gahluwalia@ucsd.edu
Groper, Danielle / dgroper@ucsd.edu
leung,taysia /t3leung@ucsd.edu (watched video)
Coyle, Jackson / jacoyle@ucsd.edu
Duan, Yihan / yid024@ucsd.edu
Xiang, Ruixuan / r1xiang@ucsd.edu
Yamashita, Daichi / dyamashita@ucsd.edu
Chen, Wenxin / wec027@ucsd.edu
Tan,Jingyi/j3tan@ucsd.edu
## NOTES:
chatGPT - can be used for debugging code
```python=
import matplotlib.pyplot as plt #import matplotlib library to use pyplot
```
```python=
time = [0,1,2,3]
position = [0, 100, 200, 300]
plt.plot(time, position) # inside plot function, type "x" values first, then comma, then "y" values
plt.xlabel('time (hr)')
plt.ylabel('position(km)')
plt.show()
```
Using Pandas - used to import csv files into the notebook
```python=
import pandas as pd
#read in data
data = pd.read_csv('gapminder_gdp_oceania.csv', index_col='country') #use help(pandas) ro learn more about the library
print(data)
```
```python=
data = pd.read_csv('gapminder_gdp_oceania.csv', index_col='country') #use help(pandas) ro learn more about the library
print(data)
years = data.columns.str.replace('gdpPercap_', '') #take out 'gdpPercap phrase before actual year
data.columns = years.astype(int) #convert string values in 'years' variable to integer values.
data.loc['Australia'].plot()
```
Creating bar plot
```python=
data.T.plot()
plt.ylabel('GDP per capita')
plt.style.use('ggplot')
data.T.plot(kind='bar')
plt.ylabel('GDP per capita')
```
### Creating lists
difference between lists and tuples
lists can be modified
Tuples cannot be modified
```python=
print('pressures:')
print('length:', len(pressure))
```
```python=
pressures[0] = 0.265
print(new first element of list, pressures[4])
print('updated pressure, pressure')
```
```pytyhon=
del pressures[3]
print('updated pressure values:')
```
# For loops
```python=
for number in [2, 3, 5]:
print(number)
```
**make sure to check indentation, if indentation is not correct, you will see an error**
```python=
primes = [2,3,5]
for p in primes:
values_squared = p ** 2 #use ** to raise any number to a power of something
values_cubed = p ** 3
print(p, values_squared, values_cubed)
```
## Session 5 Questions:
Please enter any questions not answered during live session here:
1.
### End Day 5
## Session 6
### Name (Last, First) / Email
Doe, John / jdoe@ucsd.edu (example)
Yamada, Sohei / syamada@ucsd.edu
Ahluwalia, Gurkriti / gahluwalia@ucsd.edu
Cuevas, Christopher / ccuevas@ucsd.edu
Nakamura, Masaki / m1nakamura@ucsd.edu
leung,taysia /t3leung@ucsd.edu (watched video)
Ito, Yoshi/ yoito@ucsd.edu
Weitong Li / wel056@ucsd.edu
Xiang, Ruixuan / r1xiang@ucsd.edu
Yamashita, Daichi / dyamashita@ucsd.edu
Groper, Danielle / dgroper@ucsd.edu
Artan, Warsan / wartan@ucsd.edu
Coyle, Jackson / jacoyle@ucsd.edu
Chen, Wenxin / wec027@ucsd.edu
Yamakawa, Daisuke / dayamakawa@ucsd.edu
Tan,Jingyi /j3tan@ucsd.edu
## Session 6 Questions:
Please enter any questions not answered during live session here:
1.
### End Day 6