<jupyter_start><jupyter_text>Weather in Asian Capital Cities Each column from the site below was scraped and placed into lists. The resulting lists:<jupyter_code>## (temps_f is the temperature in fahrenheits)
asian_caps = ['Amman', 'Ankara', 'Ashgabat', 'Baghdad', 'Baku', 'Bandar Seri Begawan', 'Bangkok', 'Beijing', 'Beirut', 'Bishkek', 'Damascus', 'Doha', 'Dushanbe', 'Hanoi', 'Islamabad', 'Jakarta', 'Jerusalem', 'Kathmandu', 'Kuala Lumpur', 'Kuwait City', 'Muscat', 'New Delhi', 'Nicosia', 'North Nicosia', 'Nursultan', 'Phnom Penh', 'Pyongyang', 'Riyadh', 'Seoul', 'Singapore', 'Sri Jayawardenepura Kotte', 'Taipei', 'Tashkent', 'Tbilisi', 'Tehran', 'Thimphu', 'Tokyo', 'Ulaanbaatar', 'Vientiane', 'Yerevan']
asian_countries = ['Jordan', 'Turkey', 'Turkmenistan', 'Iraq', 'Azerbaijan', 'Brunei', 'Thailand', 'China', 'Lebanon', 'Kyrgyzstan', 'Syria', 'Qatar', 'Tajikistan', 'Vietnam', 'Pakistan', 'Indonesia', 'Israel', 'Nepal', 'Malaysia', 'Kuwait', 'Oman', 'India', 'Cyprus', 'Cyprus', 'Kazakstan', 'Cambodia', 'North-Korea', 'Saudi-Arabia', 'South-Korea', 'Singapore', 'Sri-Lanka', 'Taiwan', 'Uzbekistan', 'Georgia', 'Iran', 'Bhutan', 'Japan', 'Mongolia', 'Laos', 'Armenia']
times = ['Mon 9:00 pm', 'Mon 10:00 pm', 'Tue 12:00 midnight', 'Mon 10:00 pm', 'Mon 11:00 pm', 'Tue 3:00 am', 'Tue 2:00 am', 'Tue 3:00 am', 'Mon 9:00 pm', 'Tue 1:00 am', 'Mon 9:00 pm', 'Mon 10:00 pm', 'Tue 12:00 midnight', 'Tue 2:00 am', 'Tue 12:00 midnight', 'Tue 2:00 am', 'Mon 9:00 pm', 'Tue 12:45 am', 'Tue 3:00 am', 'Mon 10:00 pm', 'Mon 11:00 pm', 'Tue 12:30 am', 'Mon 9:00 pm', 'Mon 9:00 pm', 'Tue 1:00 am', 'Tue 2:00 am', 'Tue 4:00 am', 'Mon 10:00 pm', 'Tue 4:00 am', 'Tue 3:00 am', 'Tue 12:30 am', 'Tue 3:00 am', 'Tue 12:00 midnight', 'Mon 11:00 pm', 'Mon 10:30 pm', 'Tue 1:00 am', 'Tue 4:00 am', 'Tue 3:00 am', 'Tue 2:00 am', 'Mon 11:00 pm']
temps_f = ['50', '37', '45', '54', '45', '81', '82', '35', '57', '30', '46', '68', '46', '61', '73', '79', '57', '52', '81', '68', '72', '58', '65', '65', '7', '79', '17', '73', '19', '81', '86', '52', '39', '40', '43', '27', '43', '-6', '70', '26']
conditions = ['Clear. Cool.', 'Clear. Chilly.', 'Overcast. Quite cool.', 'Clear. Cool.', 'Clear. Quite cool.', 'Partly cloudy. Warm.', 'Fog. Warm.', 'Clear. Chilly.', 'Passing clouds. Cool.', 'Overcast. Chilly.', 'Clear. Cool.', 'Clear. Mild.', 'Overcast. Cool.', 'Passing clouds. Refreshingly cool.', 'Scattered clouds. Mild.', 'Overcast. Warm.', 'Clear. Cool.', 'Fog. Cool.', 'Passing clouds. Warm.', 'Clear. Mild.', 'Clear. Mild.', 'Clear. Cool.', 'Passing clouds. Mild.', 'Passing clouds. Mild.', 'Light snow. Mostly cloudy. Frigid.', 'Passing clouds. Warm.', 'Clear. Cold.', 'Clear. Mild.', 'Clear. Cold.', 'Passing clouds. Warm.', 'Passing clouds. Warm.', 'Passing clouds. Cool.', 'Sprinkles. Overcast. Chilly.', 'Overcast. Quite cool.', 'Passing clouds. Quite cool.', 'Passing clouds. Chilly.', 'Quite cool.', 'Clear. Frigid.', 'Fog. Mild.', 'Fog. Chilly.']
## print out each list to see what you have
print(asian_caps)
print(asian_countries)
print(times)
print(temps_f)
print(conditions)
## Use a for loop to convert all temperatures from fahrenheit to celsius. 
## store results in a new list called temps_c.
## The numbers stored in the temps_c list must have NO decimal places
temps_c = []
for temp in temps_f:
    temp_c = round((temp) - 32) * (5/9)
#     print(f"{temp} degrees in fahrenheits is equal to {temp_c:,.0f} in celsius")
    temps_c.append(temp_c)

print(temps_c)<jupyter_output><empty_output><jupyter_text>Do the same thing as above but use **List Comprehension**<jupyter_code>## Call the list temps_celsius
## Remember to round so there are no decimal places.
temps_celsius = [round((int(tempf)-32)*(5/9)) for tempf in temps_f]
print(temps_celsius)
## Print each Asian country with its relevant data.
## Print in the following format:
## Country, City, Temperature in celsius like 23°C, Time, Conditions.

for (country, city, temp, condition, time) in zip(asian_countries, asian_caps, temps_c, conditions, times):
    print(f"{country}, {city}, {temp}°C, {time}, {condition}")
## Instead of just printing, place each country's data into a dictionary
## Plade each dict into a list of dictionaries called asian_cap_temps = []

asian_cap_temps = []
for (country, city, temp, condition, time) in zip(asian_countries, asian_caps, temps_c, conditions, times):
    asian_temps = {"country": country, "city": city, "temperature": temp, "conditions": condition, "time": time}
    asian_cap_temps.append(asian_temps)
print(asian_cap_temps)
## Write a for loop to traverse the dictionary you just created to 
## print out each country and its capital in the following format:
## Jordan ---> Amman
for nationcap in asian_cap_temps:
    capital = nationcap.get("city")
    nation = nationcap.get("country")
    print(f"{nation} ---> {capital}")
## Below the the generator to create a list of 10 random numbers anywhere from -10 to 10
## Run this cell to create that list of numbers
import random
numbers = random.sample(range(-5, 5), 10)
numbers
## Write statement with the following conditions:
## if there is a zero in the list, prints "There is at least one zero in this list"
## if there is not a single zero in the list, prints "There are no zeros in this list"
if 0 in numbers:
    print("There is at least one zero in this list")
else: print("There are no zeros in this list.")
## In class we built a conditional statement that
## tells us if the last number and the penultimate number
## are positive or negative.
## print a sentence that reads:
## Here it is:
if numbers[-2] > 0:
    penultimate_status = "positive"
    
else: penultimate_status = "negative"
        
if numbers[-1] > 0:
    last_status = "positive"
else: last_status = "negative"
        
print(f"The last number ({numbers[-1]}) is {last_status} while \
the second to last number({numbers[-2]}) is {penultimate_status}")
## Tweak the code in case at least one of the two last numbers hold zero(s) 
if numbers[-2] > 0:
    penultimate_status = "positive"
elif numbers[-2] == 0:
        penultimate_status = "zero"   
else: penultimate_status = "negative"
        
if numbers[-1] > 0:
    last_status = "positive"
elif numbers[-1] == 0:
        last_status = "zero"
else: last_status = "negative"
        
print(f"The last number ({numbers[-1]}) is {last_status} while \
the second to last number({numbers[-2]}) is {penultimate_status}")<jupyter_output>The last number (-2) is negative while the second to last number(0) is zero<jupyter_text>Challenge (only because this is convoluted)<jupyter_code>## Write a conditional statement that takes the previous variables and determines
## the direction of the flow.
## For example, is the flow going to positive to negative? Or from negative to positive?
## Or staying negative to negative, etc.
## Use the following phrases to describe the directions:
## "remained positive" , "turned positive" , "remained negative" , "fell to negative territory"
## "dropped from positive to zero" , "stayed flat at zero", "rose from negative territory to zero"
## fell from zero to negative territory
## For example "The flow fell from zero to negative territory: 0 to -5"

if last_status == "positive" and penultimate_status == "positive":
    flow = "remained positive"   
elif last_status == "positive" and penultimate_status =="negative":
    flow = "turned positive"    
elif last_status == "negative" and penultimate_status == "negative":
    flow = "remained negative"
elif last_status == "negative" and penultimate_status == "positive":
    flow = "fell to negative territory"
elif last_status == "zero" and penultimate_status == "positive":
    flow = "dropped from positive to zero"
elif last_status == 0 and penultimate_status == 0:
    flow = "stayed flat at zero"
elif last_status == 0 and penultimate_status == "negative":
    flow = "rose from negative territory to zero"
elif last_status == "negative" and penultimate_status == "zero":
    flow = "fell from zero to negative territory"
# else:
#     print("Nothing adds up")

print(f"The flow {flow}: {numbers[-2]} to {numbers[-1]} ")<jupyter_output>The flow fell from zero to negative territory: 0 to -2
{'fraction_non_alphanumeric': 0.16048929663608563, 'fraction_numerical': 0.032293577981651375, 'mean_word_length': 4.741573033707865, 'pattern_counts': {'":': 12, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '331102', 'license': 'MIT', 'n_tokens_mistral': 2990, 'n_tokens_neox': 2699, 'n_words': 1025, 'path': 'homework solutions/Homework for week 4 SOLUTIONS.ipynb', 'repo_name': 'sandeepmj/practical_python_exercises', 'size': '8175'}