Answer:
The height of the ball after t seconds is h + vt - 16t 2 feet:
def main():
getInput()
def getInput():
h = int(input("Enter the initial height of the ball: ")) # Adding the int keyword before input() function
v = int(input("Enter the initial velocity of the ball: ")) # Same as above
isValid(h,v)
def isValid(h,v):
if ((h <= 0) or (v <= 0)):
print("Please enter positive values")
getInput()
else:
maxHeight(h,v)
def maxHeight(h,v):
t = (v/32)
maxH = (h + (v*h) - (16*t*t))
print ("\nMax Height of the Ball is: " + str(maxH) + " feet")
ballTime(h, v)
def ballTime(h,v):
t = 0
ballHeight = (h + (v*t) - (16*t*t))
while (ballHeight >= 0):
t += 0.1
ballHeight = (h + (v*t) - (16*t*t))
print ("\nThe ball will hit the ground approximately after " + str(t) + " seconds")
# Driver Code
main()
Answer:
I am writing a python code.
def getInput():
h = int(input("enter the height: "))
v = int(input("enter the velocity: "))
isValid(h,v)
def isValid(h,v):
if (h<= 0 or v<=0):
print("not positive ")
else:
height = maximumHeight(h,v)
print("maximum height of the ball is", height," ft.")
balltime = ground_time(h,v)
print("The ball will hit the ground after", balltime, "s approximately.")
def maximumHeight(h,v):
t = (v/32)
maxheight = (h + (v*t) - (16*t*t))
return maxheight
def ground_time(h,v):
t = 0.1
while(True):
heightofball = (h + (v*t) - (16*t*t))
if (heightofball <= 0):
break
else:
t += 0.1
return t
Explanation:
There are four functions in this program.
getInput() function is used to take input from the user which is height and velocity. h holds the value of height and v holds the value of velocity. input() function is used to accept values from the user.
isValid() function is called after the user enters the value of height and velocity. This function first checks if the value of height and velocity is less than 0. If it is true the message not positive is displayed. If its false then maximumHeight() is called which returns the maximum height of the ball and function ground_time() is called to return the time when the ball will hit the ground.
maximumHeight() function first divides the value of velocity with 32 as the ball will reach its maximum height after v/32 seconds. It then returns the maximum height by using the formula: heightofball = (h + (v*t) - (16*t*t)).
ground_time() calculates the time the ball takes to reach the ground. There is a while loop to height after every 0.1 second and determine when the height is no longer a positive. It uses (h + (v*t) - (16*t*t)) formula to calculate the height and when the value of height gets less than or equal to 0 the loop terminates otherwise it keeps calculating the height while adding 1 to the value of t at each iteration. After the loop breaks, it returns the value of t.
To see the output of the maximum height and time taken by ball to reach the ground, you can call the getInput() function at the end of the above program as:
getInput()
Output:
enter the height: 9
enter the velocity: 10
maximum height of the ball is 10.6525 ft.
the ball will hit the ground after 1.2 s approximately.
Answer:
The advantage and the disadvantage of the relevant query are illustrated in the explanation in the paragraph below.
Explanation:
Advantage:
Disadvantage:
Answer:
def readFile(filename):
dict = {}
with open(filename, 'r') as infile:
lines = infile.readlines()
for index in range(0, len(lines) - 1, 2):
if lines[index].strip()=='':continue
count = int(lines[index].strip())
name = lines[index + 1].strip()
if count in dict.keys():
name_list = dict.get(count)
name_list.append(name)
name_list.sort()
else:
dict[count] = [name]
print(count,name)
return dict
def output_keys(dict, filename):
with open(filename,'w+') as outfile:
for key in sorted(dict.keys()):
outfile.write('{}: {}\n'.format(key,';'.join(dict.get(key))))
print('{}: {}\n'.format(key,';'.join(dict.get(key))))
def output_titles(dict, filename):
titles = []
for title in dict.values():
titles.extend(title)
with open(filename,'w+') as outfile:
for title in sorted(titles):
outfile.write('{}\n'.format(title))
print(title)
def main():
filename = input('Enter input file name: ')
dict = readFile(filename)
if dict is None:
print('Error: Invalid file name provided: {}'.format(filename))
return
print(dict)
output_filename_1 ='output_keys.txt'
output_filename_2 ='output_titles.txt'
output_keys(dict,output_filename_1)
output_titles(dict,output_filename_2)
main()
Explanation:
Answer:
The answer is "O(n2)"
Explanation:
The worst case is the method that requires so many steps if possible with compiled code sized n. It means the case is also the feature, that achieves an average amount of steps in n component entry information.
Answer:
Yes
Explanation:
I will say Yes. There are very much limitless possible and future we can expect from social media and even more from social networking. Its capabilities from upcoming software in the future. Since the Internet is in its early days of growing and cloud computing being introduced there are way more possibilities in the future.
Social media can be duely applied by CIT (Computer Information Technologies) graduates. It can be used to improve them in their career and also will helps them connect professionally. Quora is one such platform which is not exactly like LinkedIn but pretty much serves the purpose.
Ex: If the input is:
Enter the number of integers in your list: 5
Enter the 5 integers:
50
60
140
200
75
Enter the threshold value: 100
the output is:
The integers that are less than or equal to 100 are:
50
60
75
The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75. Such functionality is common on sites like Amazon, where a user can filter results. Your code must define and call the following two functions: def get_user_values() def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold) Utilizing functions will help to make your main very clean and intuitive.
Answer:
def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):
for value in user_values:
if value < upper_threshold:
print(value)
def get_user_values():
n = int(input())
lst = []
for i in range(n):
lst.append(int(input()))
return lst
if __name__ == '__main__':
userValues = get_user_values()
upperThreshold = int(input())
output_ints_less_than_or_equal_to_threshold(userValues, upperThreshold)
Explanation:
Answer:
A computer is an electronic device that manipulates information, or data. It has the ability to store, retrieve, and process data. You may already know that you can use a computer to type documents, send email, play games, and browse the Web
Explanation:
Follow me..............
central processor unit (CPU)
memory (ram)
input (mouse keyboard)
output (monitor or printer)
browse the web
ability to store retrieve and process data
I don't rlly know much about technology but I hope this helps