1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
olganol [36]
3 years ago
8

Write a script which: Uses the input function to get any number and store it in a variable named my_number Create a new variable

named calculation which equals my_number plus 9 Multiply calculation by 2 Subtract 4 from calculation Divide calculation by 2 Subtract my_number from calculation Print calculation
Computers and Technology
1 answer:
WINSTONCH [101]3 years ago
7 0
<h3><u>Answer:</u></h3>

# Using the input function

# Prompt the user to input some number

# Convert the input to a float - this will cater for both floating

# numbers and integers

# Store the result in a variable called my_number

my_number = float(input('Please enter some number '))

#Create a variable named calculation which equals my_number plus 9

calculation = my_number + 9

#Multiply calculation by 2

calculation *= 2

#Subtract 4 from calculation

calculation -= 4

#Divide calculation by 2

calculation /= 2

#Subtract my_number from calculation

calculation -= my_number

#Print calculation

print('calculation = ' + str(calculation))

<h2><u>Sample Output</u></h2>

>> Please enter some number 8

calculation = 7.0

<h2><u>Explanation:</u></h2>

The above program has been written in Python and it contains comments explaining each line of the code. Please go through the comments. A sample output has also been provided.

You might be interested in
Six security issues and six descriptions are shown below.
Trava [24]

Answer:

The answer to this question is given below in the explanation section

Explanation:

This question contains six securities terms and definitions.

The goal of this question is to properly map the term to its correct description/definition.

You can find the complete mapping in the attached image.

7 0
2 years ago
Which option in a Task element within Outlook indicates that the task is scheduled and will be completed on a later date?
dalvyx [7]

Answer:

in progress

Explanation:

it is being answered by the person

3 0
3 years ago
Web browsers communicate with web servers using the ____ communication protocol.
jolli1 [7]
It is the HTTP protocol.
7 0
3 years ago
DNS forwarding can be set up so that if the DNS server that receives the forwarded request cannot resolve the name, then the ser
hoa [83]

Answer:

Nonexclusive forwarding

Explanation:

In Nonexclusive forwarding, DNS forwarding is setup so that if the DNS server receiving the forwarded request cannot resolve the name, then the server that originally forwarded the request makes an attempt to resolves it. If that fails, the server sends a request to its designated forwarder.

8 0
2 years ago
php Exercise 3: Function Write a function named word_count that accepts a string as its parameter and returns the number of word
Bingel [31]

Answer:

<?php  

function word_count($string){   // function that takes a string a parameter and returns the number of words in that string

   $space = 0;   // this variable is used in order to detect space, new line and tab spaces in a string

   $words = 1; // this variable is used to identify word presence in string

   $include = $space;  //used to maintain the state of $words and $space

   $counter = 0;  // this counts the number of words in the string

   $i = 0;  //this moves through each character of the string

   while ($i < strlen($string)){  // iterates through every character of string until the last character of string is reached

       if ($string[$i] == " "||$string[$i] == "\n" || $string[$i] == "\t")  //if the space or new line or tab space is identified in the string

           $include = $space;  //set the state of include as space if the next character is a space newline or a tab space

       else if ($include == $space) {  //if next character is a word and current state i.e. $include holds $space

           $include = $words;   //  then set the state i.e. $include as $words

           ++$counter; } //increments i to move to next character at each iteration

       ++$i;  } //returns the number of words in a string

   return $counter; }

$str = "Hello, how are you ";  //sample string

echo "Words: " . word_count($str);  // calls word_count function to return number of words in str.

?>  

Explanation:

The program has a function word_count that accepts a string as its parameter and returns the number of words in the string. In the function there are three variables $space and $words and $include used as state variables. For instance $space identifies space, new line and tab spaces in the $string so it specifies that a space has occurred. $words identifies words in the $string so it specifies that a word has occurred. $include holds this state information. $i moves through every character of the $string and when a space occurs in the $string then the state $include is set to $space. When a word occurs then state $include is set to $words. $counter variable, which is used to count the number of words is incremented to 1 when previous state is $space and next character is a word character. Every time a word is seen in the string, this variable is incremented to 1 to keep track of number of words in the string. When $i reaches the end of the string then this loop stops and counter returns the number of words in the $string.

5 0
3 years ago
Other questions:
  • Why should you thank the customer after resolving an issue?
    7·2 answers
  • What is virtual reality?
    10·1 answer
  • To complete this quest, answer the following questions in the submission box below. Make x an array going from 0 to 100 by steps
    15·1 answer
  • Assume that a signal is encoded using 12 bits. Assume that many of the encodings turn out to be either 000000000000, 00000000000
    9·1 answer
  • . How to insert Section Break in Microsoft word 2016 ?
    14·1 answer
  • Excel spread sheets are primarily used to
    13·2 answers
  • Explains why we use tables in documents; and is at least three sentences long in word office 360​
    15·1 answer
  • Thabo has a small barber shop and he uses Microsoft applications to keep track of his stock and to create posters for advertisin
    12·1 answer
  • What are 3 customizations that can be done using the header/footer section in the customize reports tray?.
    14·1 answer
  • What are the functions of information technology?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!