[solved] – Question 97165
What is an example of a program that would involve processing files? Classify these programs as employing either batch or interactive processing.
Expert Answer
[solved] – Question 97171
Write a program that asks the user to enter a single character and then outputs the ASCII number of that character. Please follow the same format as in the sample run.
Try it: What happens if you type in a word like paper?
Sample Run
Enter a character: %
ASCII #37
Enter a character: 8
ASCII #56
Expert Answer
[solved] – Question 97173
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
Expert Answer
[solved] – Question 97177
Write a program to input 6 numbers. After each number is input, print the biggest of the numbers entered so far.
Example:
Enter a number: 1
Largest: 1
Enter a number: 3
Largest: 3
Enter a number: 4
Largest: 4
Enter a number: 9
Largest: 9
Enter a number: 3
Largest: 9
Enter a number: 5
Largest: 9
(Please answer I’ve been stuck on this problem for days)
Expert Answer
[solved] – Question 97187
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 a 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 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”.
Expert Answer
[solved] – Question 97204
Scalar variables. Make the following variables
a. a =10
b. b = 2.5´1023
c. c = +2 3i , where i is the square root of -1
j2 / p 3 d. = , where j is the square root of -1 and e is Euler’s number1 d e (use exp, pi)
Expert Answer
[solved] – Question 97225
Write a program that asks the user to input a word or phrase and then outputs the following information about that phrase:
“All numbers”, if the input is all numbers.
“Does not contain numbers”, if the input does not contain any numbers.
“Contains a {digit}” for each number in the phrase.
Sample Run
Enter your word or phrase: 555
All numbers
Enter your word or phrase: We are #1!
Contains a 1
Enter your word or phrase: a1b2c3d
Contains a 1
Contains a 2
Contains a 3
Enter your word or phrase: computer science
Does not contain number
Expert Answer
[solved] – Question 97226
Write a program to generate passwords. The program should ask the user for a phrase and number, and then create the password based on our special algorithm. The algorithm to create the password is as follows:
If the users input word is less than 8 characters, output Password not long enough.
If the users input word is greater than or equal to 8 characters, do the following:
Replace es with @
Replace s or S with $
Replace t or T with +
Capitalize the word and add the number to the end.
Sample Run
Enter your word: zebras
Enter a number: 62
Password not long enough.
Enter your word: newyorkcity
Enter a number: 892
Password: N@wyorkci+y892
Expert Answer
[solved] – Question 97227
Copy and paste the following code into the Solve tab. It will take data from input and put it into a file. Use the filepath variable to open the file and solve this problem.
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
file = open(filepath, ‘r’)
Write a program to find the average of the numbers stored in NewYorkTemps.txt. Be sure your output uses floating point numbers (i.e. numbers with decimals).
Expert Answer
[solved] – Question 97230
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.
books.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.
Expert Answer

