Show Menu
Cheatography

Exam #3 Cheat Sheet (DRAFT) by

cheat sheet for programming test #3

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Day 14

def hello():
       print("hello world")
invoke it with hello()

def welcome(name):
        print(f'Hello, {name}")
invoke it with welcom("amy"

def welcome_greeting(name, greeting)
        print(f' Hey{name}. {greeting}")
invoke it with welcome_greeting('Liz', "How are you?") --> Kwargs

def exponent(base,exponent):
       power = base ** exponent
       return power
num1 = 2
num2 = 3
answer = exponent(num1,num2)
print(answer)
print(exponent(2,3))

def sum(*parameters): --> unlimited parameters
        total = 0
for i in parameters:
        total = total + each_number
        return total
sum = sum(1,2,3,4,5)
print(sum)
 

Day 15

import pandas as pd
data_list = [45,74,78]
series_of_numbers = pd.series(data_list)
print(serties_of_numbers[1]) --> 74

Years = [2021, 2022, 2023]
series_of_numbers = pd.series(data=data_list, index=years)
print(series_of_numbers)
print(series_of_numbers[2021] --> 2021

grades = {'A': 34, 'B': 56}
grade_series = pd.series(data=grades)
print(grade_series) or print(grade_series['A']

quiz_scores = {
             'Quiz1': [32,56,56],
             'Quiz2': [78,34,32]}
df = pd.DataFrame(data=quiz_scores)
print(df)
# to overwrite -->
df = pd.DataFrame(data=quiz_scores. index=['mike', 'susan', 'amy']

df.head() --> top 5 rows
df.tail() --> bottom 5 rows
df[40:60] --> rows 40-59