



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




times_traveledA = int(input()) times_traveledB = int(input()) times_traveledC = int(input()) EmployeeA = 15.62 #miles EmployeeB = 41.85 #miles EmployeeC = 32.67 #miles distan e_traveledA = EmployeeA * times_traveledA๐ distan e_traveledB = EmployeeB * times_traveledB๐ distan e_traveledC = EmployeeC * times_traveledC๐ total_distan e_traveled = distan e_traveledA + distan e_traveledB + distan e_traveledC๐ ๐ ๐ ๐ print("Distan e: {:.2f} miles".format(total_distan e_traveled))๐ ๐ #2: oun es_per_pound = 16๐ pounds_per_ton = 2000 num_oun es = int(input())๐ tons = num_oun es // (oun es_per_pound * pounds_per_ton)๐ ๐ remaining_oun es = num_oun es % (oun es_per_pound * pounds_per_ton)๐ ๐ ๐ pounds = remaining_oun es // oun es_per_pound๐ ๐ remaining_oun es = remaining_oun es % oun es_per_pound๐ ๐ ๐ print("Tons: {}".format(tons)) print("Pounds: {}".format(pounds)) print("Oun es: {}".format(remaining_oun es))๐ ๐ #3: index_value = int(input()) name = various_data_types[index_value] data_type = type(name).name print(f"Element {index_value}: {data_type}") #4: b1 = int(input()) b2 = int(input()) h = int(input()) area_value = ((b1 + b2) / 2) * h print("Trapezoid area: {:.1f} square meters".format(area_value))
num1 = int(input()) num2 = int(input()) num3 = int(input()) num4 = int(input()) num5 = int(input()) integer_sum = num1 + num2 + num3 + num4 + num float_sum = float(num1) + float(num2) + float(num3) + float(num4) + float(num5) string_sum = str(num1) + str(num2) + str(num3) + str(num4) + str(num5) print("Integer: {}".format(integer_sum)) print("Float: {}".format(float_sum)) print("String: {}".format(string_sum)) #6: student_id = int(input()) student_id_string = str(student_id) first3 = student_id_string[0:3] se ond2 = student_id_string[3:5]๐ last4 = student_id_string[5:] print(f"{first3}-{se ond2}-{last4}")๐ #7: predef_list = [4, -27, 15, 33, -10] boolean_value = False max_value = max(predef_list) num = int(input()) if num > max_value: boolean_value = True print("Greater Than Max? {}".format(boolean_value)) else: print("Greater Than Max? {}".format(boolean_value)) #8: temperature = int(input()) if temperature >= 212: print("Boiling") if temperature == 212: print("Caution: Hot!") if temperature in range(115, 212): #115- print("Hot") if temperature in range(80, 115): #80- print("Warm") if temperature in range(33, 80): #33- print("Cold") if temperature < 33:
print(store_item, "${:.2f}".format(total_ ost))๐ if num_items >= 21: dis ount = total_ ost * 0.10๐ ๐ total_ ost = total_ ost - dis ount๐ ๐ ๐ print(store_item, "${:.2f}".format(total_ ost))๐ #12: def words_in_file(file): with open(file, "r") as f: words = [word.rstrip() for word in f.readlines()] senten e = " ".join(words)๐ with open(file, "a") as f: f.write("\n" + senten e)๐ with open(file, "r") as f: print(f.read()) file = input() words_in_file(file) #13: import ๐sv input1 = input() with open(input1, "r") as f: data = [row for row in ๐sv.reader(f)] for row in data: even = [row[i].strip() for i in range(0, len(row), 2)] odd = [row[i].strip() for i in range(1, len(row), 2)] pair = di t(zip(even, odd))๐ print(pair) #14: import math num = int(input()) boolean_value = False fa torial_value = math.fa torial(num)๐ ๐ if fa torial_value > 100:๐ boolean_value = True print(fa torial_value)๐ print(boolean_value) else:
print(fa torial_value)๐ print(boolean_value) #15: import pigAge def pigAge_ onverter(pigs_age):๐ return pigs_age * 5 pigs_age = int(input()) ๐ onverted_pigs_age = pigAge_ onverter(pigs_age) ๐ print(f"{pigs_age} is { onverted_pigs_age} in human years")๐