Lab 2

docx

School

Arizona State University *

*We aren’t endorsed by this school

Course

360

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

4

Uploaded by ProfStraw17234

Report
Jordan Whitecar IFT 360 Lab 2 # -*- coding: utf-8 -*- """ Created on Sun Oct 15 12:34:30 2023 @author: jorda """ #concept 1 print("concept 1 output:") #adding this to make the outputs of this lab more readable intvar = int(27) flovar = float(5.123) strvar = str("dumbvariable") print("variable values:", intvar, flovar, strvar)
#concept 2 print("concept 2 output:") #adding this to make the outputs of this lab more readable ranvar = "17" print(ranvar) ranvar = int(17) print(ranvar) #concept 3 print("concept 3 output:") #adding this to make the outputs of this lab more readable fivelist = [10, 20, 30, 40, 50] print("list:", fivelist) print("third value:", fivelist[2]) fivelist.append(60) print("updated list:", fivelist) #concept 4 print("concept 4 output:") #adding this to make the outputs of this lab more readable c4list = ["Aaron", "Kyle", "Don", "Gwen", "Danielle"] for i in range(len(c4list)): print(c4list[i]) #concept 5
print("concept 5 output:") #adding this to make the outputs of this lab more readable print("there was no code added in concept 5, just comments") #trying to make my code more readable and organized, #turns out, I'm making it harder than it needs to be! #concept 6 print("concept 6 output:") #adding this to make the outputs of this lab more readable phonebook = { "Aaron":"915-555-1234", "Kyle":"916-555-9876", "Danielle":"215-555-6655" } for x in phonebook.keys(): print(x) for y in phonebook.values(): print(y) for z in phonebook.items(): print(z) phonebook["Raj"] = "123-555-6789" print(phonebook) phonebook.pop("Raj") print(phonebook)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
#killed 2 birds with 1 stone: instead of printing keys and values twice, i just utilized the for loop earlier in the code #concept 7 print("concept 7 output:") with open("names.txt", "r") as names: for line in names: print(line.strip()) #concept 8 print("concept 8 output:") with open("names.txt", "r") as names: for line in names: name, age_str = line.strip().split() age = int(age_str) print(name) print(age) #concept 9 import pandas as pd column_names = ["Name", "Age"] df = pd.read_csv('names.txt', sep='\t', header=None, names=column_names) max_age = df['Age'].max() min_age = df['Age'].min() print(f'Maximum Age: {max_age}') print(f'Minimum Age: {min_age}') rows_2_and_3 = df.loc[1:2] print('Rows 2 & 3:') print(rows_2_and_3)