Question 1
The code used to output messages to the screen begins with
run |
# |
output |
Flag this Question
Question 2
The code used to begin a comment in the Python program source code is
# |
Hello |
* |
Comment |
Flag this Question
Question 3
A variable name is like a(n)
input typed on a keyboard |
address in computer memory where values can be stored |
output to a computer screen |
value assigned to an address in computer memory |
Flag this Question
Question 4
It does not matter whether the print statement is written in lowercase or uppercase in Python program source code.
True |
False |
Flag this Question
Question 5
It is important that each # sign is fully left justified in the Python program source code
True |
False |
Flag this Question
Question 6
The code used to begin a statement requiring the user to type text in response to a prompt is
input |
variable |
echo |
prompt |
Flag this Question
Question 7
A prompt is a message displayed on the screen to tell the user what input is expected.
True |
False |
Flag this Question
Question 8
The parentheses around the prompt in an input statement are optional.
True |
False |
Flag this Question
Question 9
Print statements can include text strings and variables separated by commas.
True |
False |
Flag this Question
Question 10
In Python programming, concatenation means
spacing |
joining |
adding |
rounding |
Flag this Question
Question 11
One reason to concatenate variables containing text is that it allows you to control the spacing in output.
True |
False |
Flag this Question
Question 12
The symbol used to code concatenation is
* |
% |
# |
+ |
Flag this Question
Question 13
In Python, the default condition is for input to be read as text.
True |
False |
Flag this Question
Question 14
a = input("Enter a number: ")
b = input("Enter a number: ")
If two numbers, 1 and 2, are input from the keyboard as values for variables a and b, respectively, in the input statements above, the output of the statement print (a + b) is
3.0 |
an error message because you can't add numbers as text |
12 |
1+2 |
Flag this Question
Question 15
a = input("Enter a number: ")
b = input("Enter a number: ")
In order for the output of the statement print (a + b) to be the sum of a and b, the input statements for a and b shown above would have to be enclosed by which function?
sum() |
float() |
join() |
str() |
Flag this Question
Question 16
Which of the following statements will NOT cause a syntax error when you attempt to compile your program?
a = float(input("Please enter a number:")) |
a = float(input("Please enter a number:") |
a = float(input('Please enter a number:")) |
a = float(input("Please enter a number":)) |
Flag this Question
Question 17
The symbol for multiplication in Python is
* |
x |
. |
/ |
Flag this Question
Question 18
Which of the following statements will allow the output of the value of a computed variable named average to be rounded to two decimal places?
average = '%.2f' % average |
average = '%2.f' % average |
average = '%.2f' average |
average = '.2f' % average |
Flag this Question
Question 19
It makes no difference whether a sum used to calculate an average is stored as text or stored as a number.
True |
False |
Flag this Question
Question 20
After the following calculation, average = 1 + 5 / 5, the output displayed by the statement print(average) would be
depends on whether the value of average was stored as a number or as text |
2.0 |
3.0 |
1.2 |
Following are the answers to the first 10 questions with explanation and output.
1. The code used to
output messages to the screen begins with ?
Ans: print.
The "print()" function is used to display messages on the computer
screen.
2. The code used to begin a comment in the Python
program source code is ?
Ans:#.
All the Strings which contain "#" as prefix are considerd as comments and are ignored by the compilers/ interpreters.
3. A variable name is like a(n) ?
Ans: address in computer memory where values can
be stored.
Also variable names are basically the names you give to computer
memory locations which are used to store values
in a computer program.
4. It does not
matter whether the print statement is written in lowercase or
uppercase in Python program source code.
Ans: False.
It is necessary to follow the syntax
of the programming language, if not error will be thrown.
5. It is important that each # sign is fully left
justified in the Python program source code ?
Ans: True
If we put a # in middle of a string then the string followed by the
# will be considered as a comment, hence if we want to make valid
comments we must put the # sign to the extreme left. i.e the first
character of the string needs to be a # for it to qualify as valid
comment.
6. The code used to
begin a statement requiring the user to type text in response to a
prompt is ?
Ans: input.
"input()" is the function used to take input from the user.
7. A prompt is a
message displayed on the screen to tell the user what input is
expected.
Ans: True.
Using print() we can prompt the user to take actions.
8. The parentheses
around the prompt in an input statement are optional.
Ans: True.
If we are using python2.x then this is True, but for python3.x it
is necessary to include the parantheses around prompt.
9. Print statements
can include text strings and variables separated by commas.
Ans: True.
It is completely valid for print statements can include text
strings and variables separated by commas. This helps in clear and
correctly formmated output.
10. In Python
programming, concatenation means ?
Ans: joining.
In the Given example below the variable s1 contains "Hello" and
variable s2 contains "World" in the third line we join/combine
these two and assign it to a third variable s3 which then becomes
"HelloWorld". This process is called concatenation.
Do leave a thumbs up if this was helpful. Feel free to ask doubts regarding the above given solution in the comments section below.
Question 1 The code used to output messages to the screen begins with run # print...
ZYBOOKS LAB: 10.23.1 Hello, I'm trying to solve this problem with creating a program code in Python about People's Weights. Here is the question: 10.23 LAB: Warm up: People's weights (Lists) (1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list. (2 pts) Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3]...
Question 1 Not yet answered Marked out of 1.00 Not flaggedFlag question Question text The statements inside of a Python loop are known as the ____ of the loop. Select one: a. body b. expression c. counter d. block Question 2 Not yet answered Marked out of 1.00 Not flaggedFlag question Question text The Python 3 program below prints the number 3. s = "Python3" print(s[len(s)]) Select one: True False Question 3 Not yet answered Marked out of 1.00 Not...
1/ What results would be appear on the computer screen after the print statements in the following Python code? Explain what is happening in lines 4-6. animals = ["cat", "dog", "elephant", "fox", ["mouse", "bird", "beetle"]] newlist = animals print( newlist) newlist[4][0] = ["caterpillar", "butterfly"] print(newlist) print(animals) 2/ What is the result of the following Python statements: print( animals[2:4]) print(animals[-3] ) output = "fox"
Chapter 08 Python Assignment: Question 1-5 Please I need help in my python course. Question 1 The finally clause of a try statement a. can be used to recover from an exception b. is required c. can be used to display more information about an exception d. is executed whether or not an exception has been thrown 10 points Question 2 Which of the following is the correct way to code a try statement that catches any type of exception...
Computer Architecture
Project Description:
farh-to-cel.asm :
# Revised and added code taken from Hennesey and Patterson 5th edition
# to work with this simulator.
#
# Prompts a user to enter a Fahrenheit temperature as a floating point.
# Displays the converted temperature in Celcius.
# 10/28/2015
.data
const5: .float 5.0 # store a floating point constant 5.0
const9: .float 9.0
const32: .float 32.0
.align 2 # align the next string on a word boundary
.space 100
prompt: .asciiz "Please...
#include<iostream> using namespace std; int main() { float num,avg,sum=0.0; int count=0; bool moreNumbers=true; cout<<"Enter grades:"<<endl; while(moreNumbers) { cin>>num; if(num < 0) { moreNumbers=false; } else { count = count+1; sum=sum+num; } } avg=sum/count; cout<<"Average grade:"<<avg<<endl; cout<<"How many grades were entered:"<<count<<endl; return 0; } Question: We need to add another loop to check input. Just like the input loop we already have, this one should use a boolean variable as a control. So, the logic could be something like this: Loop...
Task 1: Calling a Function PROGRAM IS IN PYTHON) SHOW INPUT AND OUTPUT SCREEN SHOTS Task 1: Calling a Function Defining a function gives it a name, specifies the parameters that are to be included in the function and structures the blocks of code. Once the basic structure of a function is finalized, you can execute it by calling it from another function or directly from the Python prompt. Following is an example to call the printme() function #!/usr/bin/python 3...
For this lab, modify the python code below so it will continuously be asking user for inputs to calculate the interest earned until the user enters number 0 (zero) in principle. Once the user enters any number less or equal to 0 in principle, the program will end. here is my code: # Programming Exercise 3-14 # Local variables p = 0.0 r = 0.0 n = 0.0 t = 0.0 loop = True while loop: p = float(input('\nEnter the...
х сув мм Full Name (Print please) ITM 330 Final Exam. Fall 2018 Multiple Choice (questions 1- 41,2 points each. Mark your answer on the Scantron for these questions) 1. Consider the following code segment, how many times the while loop iterates? the Sum 10 number input('Enter a number:') while int number): thesum float(number) number int(number) - 1 None Zero or more None of the above b. At least one Ten 2. Pseudocode is an) a) hybrid language of all...
Prompt for a sequence of numbers, the last number being zero. Print the number many elements of this sequence are greater than their previous neighbor. (Code without using True or False values) Example Input Enter a Number (zero to quit): 1 Enter a Number (zero to quit): 5 Enter a Number (zero to quit): 2 Enter a Number (zero to quit): 4 Enter a Number (zero to quit): 3 Enter a Number (zero to quit): 0 Example Output Number of...