Answer:
d.#include deque
Explanation:
We have to include deque library in order to use a deque container and the syntax to include is #include<deque>.Deque is a double ended queue which is a sequence container and allows operations of contraction and expansion on both ends of the queue.Double ended queues are a special case of simple queue since in simple queue the insertion is from rear end and deletion is from front end but in deque insertion and deletion is possible at both ends rear and front.
def __init__(self,size,idNum,color ):
self.size = size
self.location = 10
self.color = color
self.idNum = idNum
def changeLocation(self,newLocation):
self.location = newLocation
manipulator
initiator
method
constructor
Answer:
The answer is a method
Explanation:
Answer:
class and self
Explanation:
class Bike:
def __init__(self, str, float):
self.color = str
self.price = float
access buffer
output buffer
transmission buffer
none of the above
Answer: Output buffer
Explanation:
Each packet switches contain multiple links which are attached to it and for individually attached link the output buffer basically store packets. Then, the router send these packets into multiple links.
In output buffer, if the packets are transmitted into the links but it finds that the link is busy with the another packet for transmission. Then, that particular packet needs to be wait in output buffer.
Therefore, the output buffer is the correct option.
The recommended approach for this:
(1) create a variable to hold the current sum and initialize it to zero,
(2) use a for loop to process each element of the list,
(3) test each element to see if it is an integer or a float, and, if so, add its value to the current sum,
(4) return the sum at the end.
student.py 1
Hef sum_lengths(value_list):
# Implement your function here. Be sure to indent your code block! Restore original file
Answer:
See explaination
Explanation:
def sum_lengths(value_list):
total = 0
for x in value_list:
if (type(x)==int) or (type(x)==float):
total += x
return total
Answer:
#include <iostream>
#include <string>
using namespace std;
int main() {
string inputMonth;
int inputDay;
cin >> inputMonth >> inputDay;
if (inputMonth == "January" && inputDay >= 1 && inputDay <= 31)
cout << "Winter" << endl;
else if (inputMonth == "February" && inputDay >= 1 && inputDay <= 29)
cout << "Winter" << endl;
else if (inputMonth == "April" && inputDay >= 1 && inputDay <= 30)
cout << "Spring" << endl;
else if (inputMonth == "May" && inputDay >= 1 && inputDay <= 30)
cout << "Spring" << endl;
else if (inputMonth == "July" && inputDay >= 1 && inputDay <= 31)
cout << "Summer" << endl;
else if (inputMonth == "August" && inputDay >= 1 && inputDay <= 31)
cout << "Summer" << endl;
else if (inputMonth == "October" && inputDay >= 1 && inputDay <= 31)
cout << "Autumn" << endl;
else if (inputMonth == "November" && inputDay >= 1 && inputDay <= 30)
cout << "Autumn" << endl;
else if (inputMonth == "March" && inputDay >= 20 && inputDay <= 31)
cout << "Spring" << endl;
else if (inputMonth == "June" && inputDay >= 1 && inputDay <= 20)
cout << "Spring" << endl;
else if (inputMonth == "June" && inputDay >= 21 && inputDay <= 30)
cout << "Summer" << endl;
else if (inputMonth == "September" && inputDay >= 1 && inputDay <= 21)
cout << "Summer" << endl;
else if (inputMonth == "September" && inputDay >= 22 && inputDay <= 30)
cout << "Autumn" << endl;
else if (inputMonth == "December" && inputDay >= 0 && inputDay <= 20)
cout << "Autumn" << endl;
else if (inputMonth == "December" && inputDay >= 21 && inputDay <= 30)
cout << "Winter" << endl;
else if (inputMonth == "March" && inputDay >= 1 && inputDay <= 19)
cout << "Winter" << endl;
else
cout << "Invalid" << endl;
return 0;
}
Answer:
FOR PYTHON!!
input_month = input()
input_day = int(input())
months= ('January', 'February','March', 'April' , 'May' , 'June' , 'July' , 'August' , 'September' , "October" , "November" , "December")
if not(input_month in months):
print("Invalid")
elif input_month == 'March':
if not(1<=input_day<=31):
print ("Invalid")
elif input_day<=19:
print("Winter")
else:
print ("Spring")
elif input_month == 'April' :
if not(1<=input_day<=30):
print("Invalid")
else:
print("Spring")
elif input_month == 'May':
if not(1<=input_day<=31):
print("Invalid")
else:
print("Spring")
elif input_month == 'June':
if not(1<=input_day<=30):
print("Invalid")
elif input_day<=20:
print ("Spring")
else:
print("Summer")
elif input_month == 'July':
if not(1<=input_day<=31):
print("Invalid")
else:
print("Summer")
elif input_month == 'August':
if not(1<=input_day<=31):
print("Invalid")
else:
print("Summer")
elif input_month == 'September':
if not(1<=input_day<31):
print("Invalid")
elif input_day<=21:
print ("Summer")
else:
print ("Autumn")
elif input_month == "October":
if not(1<=input_day<=31):
print("Invalid")
else:
print("Autumn")
elif input_month == "November":
if not(1<=input_day<=30):
print("Invalid")
else:
print ("Autumn")
elif input_month == "December":
if not(1<=input_day<=31):
print("Invalid")
elif input_day <=20:
print ("Autumn")
else:
print ("Winter")
elif input_month == 'January':
if not(1<=input_day<=31):
print("Invalid")
else:
print("Winter")
elif input_month == "February":
if not(1<=input_day<=29):
print("Invalid")
else:
print ("Winter")
Explanation:
Good luck in the rest of your class!
order. B, TB,KB, GB,MB
Answer:
TB,GB,MB,KB,B
Explanation:
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.