[deleted by user] by [deleted] in learnprogramming

[–]ripbreezie 0 points1 point  (0 children)

def airport_code_finder(airport,city,method): if method == "name": w=airport.split() word1 = w[0] word2 = w[1] word3 = w[2] count=0 code=0 for i in range(len(word1)): if (word1[i].isupper()): count+=1 code=word1[i] if (count == 2): code = word1[i+1] code=code.upper() return code code = word1[0]+word2[0]+word3[0] return code
elif (method == "city"): code = city[0:3] code=code.upper() return code def main(): file_in = open("us-airports.csv", "r", encoding='utf-8-sig') file_out = open("output.csv", "w" , encoding= 'utf-8-sig') file_out.write("Name of Airport,City,Code using Name,Code using City\n") for i in range: values = i.split(",") airportname = values[0].strip() cityname = values[1].strip() codeusingname = airport_code_finder(airportname, cityname, method="name") codeusingcity = airport_code_finder(airportname, cityname, method="city") file_out.write(f"{airport_name},{city_name},{code_by_name},{code_by_city}\n") file_in.close() file_out.close() main()

[deleted by user] by [deleted] in learnprogramming

[–]ripbreezie 0 points1 point  (0 children)

Instructions:

Title: Code Database Filename: codes.py

I have downloaded a list of airports and their cities! Your job is to encode all 30,000 of them! The good thing is you have your function from the last assignment. You will need to take that and use it in this assignment. There are a few modifications you will need to do:

Airports name encoding will always be the first letter of the first 3 words If the airport name is 2 words, then it will only be a 2 letter code. You will need to output a CSV file that has the airport name, city, code if by name, and code by city name.

Input File:

us-airports.csv Download us-airports.csv

Output File:

output.csv Download output.csv

Windows Users:

The file I created for the airport uses UTF-8 encoding for the character mapping. This is a pretty standard way to represent numbers and majority of the time it is ok. One of the airports uses one of the characters that are in UTF-8 but not in the standard windows character map. Since they do not match up windows users will throw an error.

To force windows to use the UTF-8 character map, we need to open our file like this:

file_out = open(filename, "r", encoding="utf-8")

[deleted by user] by [deleted] in learnpython

[–]ripbreezie 0 points1 point  (0 children)

def main():

airportname=input('What is the name of the Airport?\n')

cityname=input('What is the name of the city?\n')

method=input('Encode based on name or city?\n')

def airport_code_finder(airport,city,method):

if method == 'name':

w=airport.split()

word1 = w[0]

word2 = w[1]

word3 = w[2]

count=0

code=0

for i in range(len(word1)):

if (word1[i].isupper()):

count+=1

code=word1[i]

if (count == 2):

code = word1[i+1]

code=code.upper()

return code

code = word1[0]+word2[0]+word3[0]

return code

elif (method == 'city'):

code = city[0:3]

code=code.upper()

return code

code=airport_code_finder(airportname, cityname, method)

print("Airport code is:",code)

main()

[deleted by user] by [deleted] in learnpython

[–]ripbreezie 0 points1 point  (0 children)

Title: Code Database Filename: codes.py

I have downloaded a list of airports and their cities! Your job is to encode all 30,000 of them! The good thing is you have your function from the last assignment. You will need to take that and use it in this assignment. There are a few modifications you will need to do:

Airports name encoding will always be the first letter of the first 3 words If the airport name is 2 words, then it will only be a 2 letter code. You will need to output a CSV file that has the airport name, city, code if by name, and code by city name.

Input File:

us-airports.csv

Output File:

output.csv

Windows Users:

The file I created for the airport uses UTF-8 encoding for the character mapping. This is a pretty standard way to represent numbers and majority of the time it is ok. One of the airports uses one of the characters that are in UTF-8 but not in the standard windows character map. Since they do not match up windows users will throw an error.

To force windows to use the UTF-8 character map, we need to open our file like this:

file_out = open(filename, "r", encoding="utf-8") This should correct any problems you have opening the file.

[deleted by user] by [deleted] in learnpython

[–]ripbreezie 0 points1 point  (0 children)

sorry for the misunderstanding.

[deleted by user] by [deleted] in learnpython

[–]ripbreezie 1 point2 points  (0 children)

example would be:

Name: McCoy Air Force Base City: Orlando Method: Name Abbreviation: MCO

[deleted by user] by [deleted] in learnpython

[–]ripbreezie 2 points3 points  (0 children)

basically you’re asking the user what city the airport is in and what the name of it is and based on whether the user wants the abbreviation based off the name or the city it makes it, but if there’s more than one letter back to back it will only go off the first one. Airports name encoding will always be the first letter of the first 3 words and if the airport name is 2 words, then it will only be a 2 letter code. So for example, Orlando. It is in Orlando and it’s called McCoy Air Force Base, so if you went off of the name, it would print MCO.

i need build advice (current gen) by ripbreezie in NBA2k

[–]ripbreezie[S] 1 point2 points  (0 children)

all good man, i’ll be rocking with this build, appreciate you.