Question

In: Computer Science

In Python Which initial value of x will make the following piece of code leave a...

In Python

Which initial value of x will make the following piece of code leave a 9 in the final value of x?

x = ____?
if x < 7:
   x = x + 1
x = x + 2

a.

11

b.

9

c.

7

d.

None of the above

Which initial value of x will make the following piece of code leave a 20 in the final value of x?
x = ____?
if x * 2 <= 34:
   x = 0
else:
   x = x + 1

x = x + 1

a.

17

b.

18

c.

19

d.

20

e.

None of the above

What is a common word for the textual representation of a program?

a.

code

b.

prompt

c.

interpreter

d.

expression

e.

None of the above

Which statement reads a user-entered string into variable user_name?

a.

input = user_name()

b.

user_name = input()

c.

input() => user_name

d.

user_name = "input()"

e.

None of the above

What is the output?

count = 0
while count < 3:
     print('loop')
count = count + 1
print('final value of count:', count)

a.

Prints 'loop' once, then 'final value of count: 1'

b.

Prints 'loop' three times, then 'final value of count: 3'

c.

Prints 'loop' three times, then 'final value of count: 4'

d.

Prints 'loop' forever (infinite loop)

e.

None of the above

Solutions

Expert Solution

PLEASE UPVOTE THE ANSWER AND FEEL FREE TO ASK YOUR DOUBTS IN COMMENT SECTION.


Related Solutions

code in python write a code where the initial value is compounded by a multiplier, rounded...
code in python write a code where the initial value is compounded by a multiplier, rounded to the nearest tenth Output: Initial Value: 10 Multiplier: 1.4 Number of compounds: 10 Your Values are: 10 , 14, 19.6 , 27.4, 38.4, 53.8, 75.3, 105.4, 147.6, 206.6
Based on the following Python code, write a Python statement which outputs “December” when the value...
Based on the following Python code, write a Python statement which outputs “December” when the value of the Month is 12 or “November” when the value of the Month is 11 or “Neither” when value of the Month is neither 11 or 12. The user enters the value which is store in the variable namedMonth. Month = int(input("Please enter the value of the month in numerical format such as 11 for November, or 12 for December: " )) sing Python
Write the following Python code: A string X is an anagram of string Y if X...
Write the following Python code: A string X is an anagram of string Y if X can be obtained by arranging all characters of Y in some order, without removing any characters and without adding new characters. For example, each of the strings "baba", "abab", "aabb" and "abba" is an anagram of "aabb", and strings "aaab", "aab" and "aabc" are not anagrams of "aabb". A set of strings is anagram-free if it contains no pair of strings which are anagrams...
preform a piece of python code that focuses on string operations, thank you.
preform a piece of python code that focuses on string operations, thank you.
In python make a simple code. You are writing a code for a program that converts...
In python make a simple code. You are writing a code for a program that converts Celsius and Fahrenheit degrees together. The program should first ask the user in which unit they are entering the temperature degree (c or C for Celcius, and f or F for Fahrenheit). Then it should ask for the temperature and call the proper function to do the conversion and display the result in another unit. It should display the result with a proper message....
Python: I want to make the following code to prompt the user if want to run...
Python: I want to make the following code to prompt the user if want to run the software again. I am new to python, so i do not know if it works like c++. If can explain that would be much appreciated base = float(input("Enter base of the triagle: ")) Triangle_Right = float(input("Enter right side of the triagle: ")) Triangle_Left = float(input("Enter left side of the triagle: ")) height = float(input("Enter the height of the triangle: ")) perimiter = base...
Leave code as is ALL I NEED IS TO MAKE THE LIST INTO ASCENDING ORDER FROM...
Leave code as is ALL I NEED IS TO MAKE THE LIST INTO ASCENDING ORDER FROM A TO Z OF ARTISTS NAMES YOU CAN USE THIS AS REFERENCE SPOTIFY LIST TOP 50 AS REFERENCE FOR CSV FILE https://spotifycharts.com/viral/ import java.io.*; public class Spotify { public static void main(String[]args) { // Read csv Spotify file located on my desktop // Download csv file, save on desktop, and add file location in csvFile = " " String csvFile = "CSVFILE LOCATION OF...
PLEASE USE PYTHON CODE Compute the zero of the function y(x) from the following data: x...
PLEASE USE PYTHON CODE Compute the zero of the function y(x) from the following data: x = 0.2, 0.4, 0.6, 0.8, 1.0 y = 1.150, 0.855, 0.377, -0.266, -1.049 Use inverse interpolation with the natural cubic spline
Write PYTHON CODE to answer the following question: Consider the following data: x = [0, 2,...
Write PYTHON CODE to answer the following question: Consider the following data: x = [0, 2, 4, 6, 9, 11, 12, 15, 17, 19] y = [5, 6, 7, 6, 9, 8, 8, 10, 12, 12] Using Python, use least-squares regression to fit a straight line to the given data. Along with the slope and intercept, compute the standard error of the estimate and the correlation coefficient. Best fit equation y = ___ + ___ x Standard error, Sy/x =...
If you increase the y-component of a projectile’s initial velocity but leave the x-component the same,...
If you increase the y-component of a projectile’s initial velocity but leave the x-component the same, what will be true about its motion? Assume it is flying over level ground. a) The projectile will be in the air a longer time. b) The projectile will land farther away from you c) The projectile will reach a greater maximum height. d) The velocity of the projectile at its highest point will be unchanged. e) All of the above An explanation would...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT