Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

You can open and close the input file twice. This is just a recommendation. You’re welcome to find a more effective way.For the first time when you open the input file, you can get the total of all grades and the counter in order to calculate the average. You will needoA for loop or a while loop to read a grade at a time: e.g., for line in infile:For the second time when you open the input file, you can compare each grade with the average to determine if the grade is above or below the average. You will need oA for loop or a while loop to read a grade at a time: e.g., for line in infile:oConversion from a line (string) into a float: e.g., grade = float(line)oA condition structure to determine if the grade is above or below the average: e.g., if-elif statementoA counter for the number of grades above the averageoAnother counter for the number of grades below the average
def mystery1(x):
return x + 2

def mystery2(a, b = 7):
return a + b

#MAIN
n = int(input("Enter a number:"))
ans = mystery1(n) * 2 + mystery2 (n * 3)
print(ans) what is the output of the user enters -4
Use the code snippet above to write a program that uses looping to output the following shape:

THIRD
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
Instructions
In the file KnockKnock.txt (Links to an external site.), the odd lines have the answers to, "Who’s there?', and the even numbers have the answers to, "_________ who?" question.

Count the number of lines in the file, then generate a random knock-knock joke from the file.

Sample Run
Note: the extra lines are there because each line ends in a \n and students will not know how to cut those off yet.)

Knock-Knock
Who's there?
Rabbit

Rabbit
who?
Rabbit up carefully it's a present!
Describe the for loop and compare with the for-each loop by describing the operation of each and
discussing how they differ from each other. You must include the role of enums in your description and
provide an example of a for loop and a for-each loop.
You have decided to start a website and are creating a chatbot prototype to show investors so you can raise money and launch your website.

Your chatbot should ask the user the following (minimum requirements for the autograder) and then give answers depending on the answers the user inputs:

at least 5 questions, and
at least 2 if-elif-else statements.
Based on this criteria, some responses will be based on what the user types, and some will be based on random numbers.
i am making the riemann sum with x**3 but it needs to bo done with dx**3 , for example b - a / n

(5/8)**3 + 10/8**3 + 15/8**3 and this 5 times more because n is 8.

i have made this program so far , it is working with the calculation right now , but it needs to be changed to the example above. With a loop for n.


#formula to calculate dx
dx = float ((b-a)/n)

xi=a
Sum = dx
#loop
for i in range(0,n,n):
xi = a + dx
sum = Sum + f(xi)
print("the surface under the line is ", (sum*dx))
Write a loop that continually asks the user what pets the user has until the user enters rock, in which case the loop ends. It should acknowledge the user in the following format. For the first pet, it should say You have a dog with a total of 1 pet(s) if they enter dog, and so on.

Sample Run
What pet do you have? lemur
What pet do you have? parrot
What pet do you have? cat
What pet do you have? rock
Sample Output
You have a lemur with a total of 1 pet(s)
You have a parrot with a total of 2 pet(s)
You have a cat with a total of 3 pet(s)
Colin
3. How to format each item of your inverted dictionary as a text string in the output file.
My program is saying - out of range.
How can I get around this?
Consider the following Python program.

fin = open('words.txt')
for line in fin:
word = line.strip()
print(word)

What is word?
Select one:
a. A file object
b. A list of characters
c. A list of words
d. A string that may have a newline
e. A string with no newline
LATEST TUTORIALS
APPROVED BY CLIENTS