Write a program to provide information on the height of a ball thrown straight up into the air. The program should request as input the initial height, h feet, and the initial velocity, v feet per second. The height of the ball after t seconds is

Answers

Answer 1
Answer:

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 2
Answer:

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.


Related Questions

3. What is the error in the following pseudocode? // The searchName function accepts a string containing the name // to search for, an array of strings containing the names, and // an integer specifying the size of the array. The function // searches for the name in the array. If the name is found, the // string containing the name is returned; otherwise a message // indicating that the name was not found in the array is // returned. Function String searchName(String name, String names[], Integer size) Declare Boolean found Declare Integer index Declare String result // Step through the array searching for the // specified name. While found == False AND index <= size − 1 If contains(names[index], name) Then Set found = True Else Set index = index + 1 End If End While // Determine the result. If found == True Then Set result = names[index] Else Set result = "That name was not found in the array." End If Return result End Function
True / FalseIn the structure of a conventional processor, the computational engine is generally known as the arithmetic-logic unit.
What technology would you like to use or see developed that would help you be a "citizen of the world"?
Definition of letter in communication skills
Write a function namedadd_complex that adds the correspondingnumbers of its arguments (both complexstructures), then returns the result (anothercomplex structure)

Constructing a concurrent server by spawning a process has some advantages and disadvantages compared to multithreaded servers. Discuss a few.

Answers

Answer:

The advantage and the disadvantage of the relevant query are illustrated in the explanation in the paragraph below.

Explanation:

Advantage:

  • The benefit of creating a simultaneous server through spawning a mechanism seems to be that alternative methods are shielded against everyone else, which would be very necessary whenever the extremely database manages communication services entirely.

Disadvantage:

  • The downside about creating a concurrent system through spawning a methodology seems to be that this process seems to be very expensive but using multicore processing systems should save this expense. It is also easier when using threads again for the aim of communicating between two or even more participants although we stop the kernel executing the correspondence.

Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. The input file contains an unsorted list of number of seasons followed by the corresponding TV show. Your program should put the contents of the input file into a dictionary where the number of seasons are the keys, and a list of TV shows are the values (since multiple shows could have the same number of seasons).

Answers

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:

Express the worst case run time of these pseudo-code functions as summations. You do not need to simplify the summations. a) function(A[1...n] a linked-list of n integers) for int i from 1 to n find and remove the minimum integer in A endfor endfunction

Answers

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.

  • In the given code, The total of n integers lists is O(n), which is used in finding complexity.
  • Therefore, O(n)+O(n-1)+ .... +O(1)=O(n2) will also be a general complexity throughout the search and deletion of n minimum elements from the list.

One author states that Web-based software is more likely to take advantage of social networking (Web 2.0) approaches such as wikis and blogs. If this is the case, can we expect more social networking capabilities in all future software? Aside from LinkedIn, how can social media be leveraged by CIT graduates?

Answers

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.

IN PYTHON Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value.

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.

Answers

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:

What makes a computer a computer?​

Answers

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