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

Write a program that accepts a time as an hour and minute. Add 15 minutes to the time, and output the result.

Example 1:

Enter the hour: 8
Enter the minute: 15
It displays:

Hours: 8
Minutes: 30
Example 2:

Enter the hour: 9
Enter the minute: 46
It displays:

Hours: 10
Minutes: 1
1) Display the number of jokes in jokes.txt
2) Ask the user for the number of a joke
3) Display the joke
4) Display the requested joke
5) Display the requested answer

import os

# This program has read/write access to the WORKSPACE directory
jokes_filepath = os.path.join( os.environ['WORKSPACE'], 'jokes.txt' )
answers_filepath = os.path.join( os.environ['WORKSPACE'], 'answers.txt' )

# The testing system will let this program know how many lines to expect
num_of_lines = int( input() )

# Copy input into the files. Do not modify!
with open( jokes_filepath, 'w' ) as jokes_file:
with open( answers_filepath, 'w' ) as answers_file:
for _ in range( num_of_lines ):
jokes_file.write( input() + '\n' )
answers_file.write( input() + '\n' )

# Write your program below
You should ask the user at least five questions and use if-elif-else statements and give answers depending on how they answer. Some responses should be based on what they type, and some should be based on random numbers.

For example, if they say they are sad, your chatbot might respond “I’m sorry to hear that”.

You could also have a random number generated between 1 and 3 and have a corresponding response depending on the number such as “That is great to hear” or “So interesting”.
Come up with a challenging algorithm and it must contain at least 5 if statements and use at least one AND or OR boolean condition.
For this lab you will find the area of an irregularly shaped room with the shape as shown above.

Ask the user to enter the values for sides A, B, C, D, and E and print out the total room area.

Remember the formula for finding the area of a rectangle is length * width and the area of a right triangle is 0.5 * the base * height.

Please note the final area should be in decimal format.
7.1 Code Practice: Question 3
In the last problem, we get an error if we enter more than one character at a time. Rewrite the program so that it only calls the ord method if a single character is entered.

Sample Run

Enter a character: *
ASCII #42

Enter a character: exit
Not a character
The previous code was
x = input("Enter a character: ")
print ("ASCII #" + str(ord(x)))
When we read code and predict its output, it is called tracing code.

For this lesson you will come up with your own challenging algorithm for other students to trace. It must contain at least 5 if statements and use at least one AND or OR boolean condition. Run it in the sandbox below, then copy and paste your code in Piazza for other students to try.

For this challenge try reading 3 or 4 other students' code - trace the code and predict what it outputs, then run it in the sandbox to see if you got it right.
A chatbot is a computer program designed to emulate human conversation. For this program you will use if statements, user input, and random numbers to create a basic chatbot.

Here is the scenario: You have decided to start an online website. You are creating a prototype to show investors so you can raise money and launch your website. You should ask the user at least 5 questions ( 5 inputs required ) and use at least 2 if-elif-else statements and give answers depending on how they answer. Some responses should be based on what they type, and some should be based on random numbers.

For example, if they say they are sad, your chatbot might respond Im sorry to hear that.

You could also have a random number generated between 1 and 3 and have a corresponding response depending on the number such as That is great to hear or So interesting.
import os

# This program has read/write access to the WORKSPACE directory
filepath = os.path.join( os.environ['WORKSPACE'], 'yourfilename.txt' )
file = open(filepath, 'w')
Write a program to input ten book titles and authors names then save them to a file named book.txt.


For each book, the user will first input the title, then input the first name, then the last name of the author, all on separate lines. In addition to saving the books in the file, please output, using the print method, the information you've gathered from the user.

You should follow the format uppercase title, tab, capitalized last name, comma, single space, capitalized first name. Here's an example for your output:

Format:

TO KILL A MOCKINGBIRD Lee, Harper
All book titles should be in upper case and the authors name should be capitalized.
import os

# This program has read/write access to the WORKSPACE directory
filepath = os.path.join( os.environ['WORKSPACE'], 'NewYorkTemps.txt' )

# The testing system will let this program know how many lines to expect
num_of_lines = int( input() )

# Copy input into the file. Do not modify!
with open( filepath, 'w' ) as file:
for _ in range( num_of_lines ):
file.write( input() + '\n' )

# Write your program below
LATEST TUTORIALS
APPROVED BY CLIENTS