1. Engineering
  2. Computer Science
  3. this is written in python gtgtis a high school computer...

Question: this is written in python gtgtis a high school computer...

Question details

THIS IS WRITTEN IN PYTHON >>IS A HIGH SCHOOL COMPUTER SCIENCE COURSE. NOT TOO COMPLICATED PLEASE

QUESTION #1

Write code to output the ASCII characters that are represented by the numbers from 45 to 85, one per line.

Expected Output

-
.
/
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U

QUESTION #2

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

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 chr method if a single character is entered.

Sample Run

Enter a character: *
ASCII #42

Enter a character: exit
Not a character

QUESTION #4

Write a program that asks the user to input a word or phrase and then outputs the following information about that phrase:

  1. "All numbers", if the input is all numbers.
  2. "Does not contain numbers", if the input does not contain any numbers.
  3. "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 numbers

HINT 1: you may wish to use a loop that goes from the digits 0 to 9, and remember that loops can be used for processing string values when appropriate.

HINT 2: In order to at the end see if any numbers have been found, you can create a true-false variable that is initialized before your for loop, and use an if/else statement inside of that loop that modifies the variable if any numbers have been found. Variables used in this fashion are called flag variables.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution