Question
please help me with these problems using >>PYTHON < < Thunderbolts and lightning (very very frightening) When lightning strikes we see the flash before we
please help me with these problems using >>PYTHON<<
Thunderbolts and lightning (very very frightening)
When lightning strikes we see the flash before we hear the crash of thunder because light travels much faster than sound. You may assume the speed of sound is roughly 1100 feet per second and one mile is 5280 feet.
Write a function called 'find_lightning_distance' with a single parameter 'delay' which represents the delay between a lightning strike and the corresponding thunder. The function should return the distance at which the lightning strike occurred in miles.
Hint: Is there a formula that can be used to calculate distance (some kind of 'distance formula' maybe)? Hint: You should be able to write this function in less than 3 lines (maybe even one!) so if you've written 20 lines, you're overthinking it.
Chess Values
Chess pieces are commonly assigned values to provide a rough guide to the state of play. Write a function called 'get_piece_value' that takes in a single parameter 'piece' and then returns the corresponding value. If the value passed to the function is not a valid chess piece, return None.
The schema for determining the value of a chess piece is:
pawn: 1
bishop: 3
knight: 3
rook: 5
queen: 9
Numbers to words
Create a function called 'number_to_word' that takes in a single parameter that is an integer and returns a string that contains the english words that correspond to that number in lowercase. You should verify that the number is positive and is one or two digits, if it is not, you should return None
Sample run: number_to_word(42) --> 'FOURTY TWO'
Hint: Don't forget the 'teens', they're a bit of a special case
Phone Number Fixup
A company keeps phone numbers in two different formats but wants to standardize on one format. Write a function called 'standardize_phone_number' that takes in one parameter called 'phone_number'. The phone number may be in one of the below formats or neither of them. If the phone number is in either of the listed forms, the function should return the phone number in the second form. If it is not in either form, it should return None. Handling unexpected input properly may be harder than you think!
The two styles you should consider are:
(123) 456-7890
123-456-7890
Hint: strings have a method called str.isdigit(), you can read the docs here
Hint: Don't forget that strings have a str.replace() method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started