V
@Videonerd03
contact list
#A contact list is a place where you can store a specific contact with other associated information such as
#a phone number, email address, birthday, etc.
#Write a program that first takes in word pairs that consist of a name
#and a phone number (both strings), separated by a comma.
#That list is followed by a name, and your program should output
#the phone number associated with that name. Assume the search name is always in the list.
#Ex: If the input is:
#Joe,123-5432 Linda,983-4123 F
Check if list is sorted
Write the in_order() function, which has a list of integers as a parameter,
#and returns True if the integers are sorted in descending order (in order from high to low) or False otherwise.
#The program outputs "In descending order" if the list is sorted, or "Not in order" if the list is not sorted.
#Ex: If the list passed to the in_order() function is [5, 6, 7, 8, 3], then the function returns False and the program outputs:
#Not in order
#Ex: If the list passed to the in_order() function is
elements in a range
#Write a program that first gets a list of integers from input.
#That list is followed by two more integers representing lower and upper bounds of a range.
#Your program should output all integers from the list that are within that range (inclusive of the bounds).
#Ex: If the input is:
#25 51 0 200 33
#0 50
#the output is:
#25,0,33,
Filter and sort a list
#Write a program that gets a list of integers from input, and outputs negative integers in descending order (highest to lowest).
#Ex: If the input is:
#10 -7 4 -39 -6 12 -2
#the output is:
#-2 -6 -7 -39
#For coding simplicity, follow every output value by a space. Do not end with newline.
Varied amount of input data
#Statistics are often calculated with varying amounts of input data.
#Write a program that takes any number of non-negative floating-point numbers as input, and outputs the max and average, respectively.
#Output the max and average with two digits after the decimal point.
#Ex: If the input is:
#14.25 25 0 5.75
#the output is:
Driving Costs - Functions
#Write a function driving_cost()
#with parameters miles_per_gallon, dollars_per_gallon, and miles_driven
#that returns the dollar cost to drive those miles.
#All items are of type float. The function called with arguments (20.0, 3.1599, 50.0) returns 7.89975.
#The main program's inputs are the car's miles per gallon and the price of gas in dollars per gallon (both float).
#Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your driving_cost() function three times.
#Outpu
Conversion from kilo to pounds
def kilo_to_pounds(kilos):
return kilos * 2.204
#main part of the program starts here. Do not remove the line below
if__name__ == "__main__":
kilos = float(input())
pounds = kilo_to_pounds(kilos)
print(f"{pounds:.3f} lbs")
list by normalizing
#When analyzing data sets, such as data for human heights or
#for human weights, a common step is to adjust the data.
#This adjustment can be done by normalizing to values between 0 and 1, or throwing away outliers.
#For this program, adjust the values by dividing all values by the largest value.
#The input begins with an integer indicating the number of floating-point values that follow.
#Assume that the list will always contain positive floating-point values.
#Output each floating-point
Brute force equation solver
#Numerous engineering and scientific applications require finding solutions to a set of equations.
#Ex: 8x + 7y = 38 and 3x - 5y = -1 have a solution x = 3, y = 2.
#Given integer coefficients (a, b, c, d, e, and f) of two linear equations
#with variables x and y listed below, use brute force to find an integer solution for x and y in the range -10 to 10.
#ax + by = c
#dx + ey = f
a = int(input())
password modifier
#Many user-created passwords are simple and easy to guess.
#Write a program that takes a simple password and makes it stronger
#by replacing characters using the key below, and by appending "!" to the end of the input string.
#i becomes 1
#a becomes @
#m becomes M
#B becomes 8
#s becomes $
Reverse binary
positive_int = int(input())
binary = bin(positive_int)[2:]
reverse_binary = binary[::-1]
result = int(reverse_binary, 2)
print(reverse_binary)
Interstate highway numbers
#Primary U.S. interstate highways are numbered 1-99.
#Odd numbers (like the 5 or 95) go north/south,
#and evens (like the 10 or 90) go east/west.
#Auxiliary highways are numbered 100-999,
#and service the primary highway indicated by the rightmost two digits.
#Thus, I-405 services I-5, and I-290 services I-90.
#Note: 200 is not a valid auxiliary highway because 00 is not a valid primary highway number.
#Given a highway number,
#indicate whether it is a primary or auxiliary highway.
Leap year
#A year in the modern Gregorian Calendar consists of 365 days.
#In reality, the earth takes longer to rotate around the sun.
#To account for the difference in time, every 4 years, a leap year takes place.
#A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are:
#1) The year must be divisible by 4
#2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400; therefore, both 1700 and 1800
Golf Scores
#Golf scores record the number of strokes used to get teh ball in the hole
# The expected number of strokes varies from hole to hole and is called par(possible values: 3,4,5) Each score's name is based on the actual strokes
# taken compared to par:
# "Eagle": number of strokes is two less than par
# "Birdie": number of strokes is one less than par
# "Par": number of strokes equals par
#"Bogey": number of strokes is one more than par
Count characters
#Write a program whose input is a string which contains a character and a phrase, and whose output indicates
# the number of times the character appears in the phrase.
#The output should include the input character and use the plural form, n's, if the number of times the character appears is not exactly 1
#Ex if the input is:
# n Monday
# the output is:
# 1 n
Name Format
#Write a program that reads a persons name in the following format:
# firstName middleName lastName(in one line)
# and output the person's name in the following format:
# lastName, firstInitial.middleInitial
# Ex: If the input is:
# Pat Silly Doe
Uppercase and lowercase string
# upper or lowercase allowed
user_input = input()
if user_input.isalpha():
print("Yes")
else:
print("No")
Checker for integer string
# Write a program that takes in a string representing an integer as input, and outputs yes
# if every character is a digit 0-9 or No otherwise
# if the input is:
# 1995
# the output is:
# Yes
#if the input is:
Simple statistics
#Given 4 floating-point numbers. Use a string formatting expression with conversion specifiers to output their product
# And their average as integers(rounded) then as floating-point numbers
#Output each rounded integer using the following:
#print (f'{your_value:.0f}')
#Output each floating-point value with three digits after the decimal point, which can be achieved as follows:
#print (f' {your_value:.3f}')
# if the input is:
Set basics
#Given the user inputs, complete a program that does the following tasks:
#Define a set, fruits, containing the user inputs: my_fruit1, my_fruit2, and my_fruit3
#Add the user inputs, your_fruit1 and your_fruit2, to fruits
#Add your_fruit1 to fruits
#Remove my_fruit1 from fruits