2.4 Code Practice: Question 1
Write the code to input a number and print the square root. Use the absolute value function to make sure that if the user enters a negative number, the program does not crash. How do I do this in python ???

Answers

Answer 1

Code in Python:

num = float(input("Enter any number : "))

ab = abs(num)

sqrt = float(ab ** 0.5)

print(sqrt)

Answer 2

The code to input a number and print the square root is,

import math

# Input a number from the user

number = float(input("Enter a number: "))

# Use the absolute value function to handle negative numbers

abs_number = abs(number)

# Calculate the square root using the math module

sqrt_number = math.sqrt(abs_number)

# Print the square root

print(f"The square root of {number} is {sqrt_number}")

Given that,

Write the code to input a number and print the square root.

Now, A code snippet in Python that accomplishes what you described:

import math

# Input a number from the user

number = float(input("Enter a number: "))

# Use the absolute value function to handle negative numbers

abs_number = abs(number)

# Calculate the square root using the math module

sqrt_number = math.sqrt(abs_number)

# Print the square root

print(f"The square root of {number} is {sqrt_number}")

In this code, the abs() function ensures that even if the user enters a negative number, it will be converted to its positive equivalent before calculating the square root.

The math.sqrt() function is used to compute the square root, and the result is printed using the print() function.

To learn more about Function visit:

https://brainly.com/question/11624077

#SPJ6


Related Questions

How do you halt an infinite loop?
by pressing the Control key and the

key

Answers

write code creating an infinite loop, with my new Excel, the Ctrl + Break no longer works. Neither does the Esc key, etc.

I've looked all over the web and it appears that Microsoft has a bug and doesn't care to fix it.

Is there a way to re-introduce the Ctrl + Break function to VBA so if this happens in the future I don't lose work / force close?

Answer:c

Explanation:ctrl and c stops a infinite loop

Amy is not sure if the Web page loaded completely in her browser. She should look at the _____.

status bar
command toolbar
search engine
address bar

Answers

Answer:

Status Bar

Explanation:

A status bar will show the progress of the page that is being loaded.

Status bar It shows how much the page has loaded and how much it has left till fully loade

Federico is using diagrams in a PowerPoint presentation for his science project. He needs to draw four different circles on one slide. Although the circles should be different sizes, none of them should be stretched like an oval. They must be perfectly round circles.

Which sequence of buttons and keys should Federico press to draw a perfectly round circle?

A. click Design tab → click Shapes in the Drawing group → press and hold Shift → select Oval while holding Shift → left-click on the slide and drag the mouse while still holding Shift

B. click Home tab → click Shapes in the Drawing group → select Oval → press and hold Shift → left-click on the slide and drag the mouse while holding Shift

C. click Design tab → click Shapes in the Drawing group → select Oval → press and hold Shift → right-click on the slide and drag the mouse while holding Shift

D. click Home tab → press and hold Shift → click Shapes in the Drawing group → select Oval while holding Shift → right-click on the slide and drag the mouse while still holding Shift

Answers

Answer:

b

Explanation:

click Home tab → click Shapes in the Drawing group → select Oval → press and hold Shift → left-click on the slide and drag the mouse while holding Shift.

What is Powerpoint Presentation?

A complete presentation graphics suite is PowerPoint. It provides you with everything required to create a presentation that looks polished. Word editing, outlining, sketching, graphing, and presentation management tools are all available in PowerPoint, all of which are simple to use and pick up.

The slides that make up a PowerPoint presentation are what the presentation is built of. The PowerPoint slides you produce can also be shown as overhead transparencies or 35mm slides.

You can print audience handouts, outlines, and speaker's notes in addition to the slides. The robust Slide Master, which will be discussed in the tutorial, can format any slide in a presentation.

Therefore, click Home tab → click Shapes in the Drawing group → select Oval → press and hold Shift → left-click on the slide and drag the mouse while holding Shift.

To learn more about Powerpoint presentation, refer to the link:

https://brainly.com/question/22438059

#SPJ2

what is the meaning of .net in computer​

Answers

Answer:

.net is a top-level domain, also known as a TLD. Derived from the word network, it was originally developed for companies involved in networking technology. Today .net is one of the most popular domain names used by companies all over the world to launch their business online.

Animal wisdom/ the last wolf .compare and contrast the overall feeling of each poem

Answers

List the poem please. I won’t be able to answer without it.

please help me I want the answer for the 3rd question ​

Answers

Use the multiples thats are included in the flowchart and divide them by half a divisible

My friend's newborn sister is so precious.
a. ri
c. fr
b. en
d. ie

Answers

She’s not precious ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ

3. You'd prefer to read this email on a larger screen, so you open your laptop. Your laptop display is quite flat. What kind of screen do you think it is?

Answers

Answer:

.....

Explanation:

Answer:

plasma Screens

Explanation:

Used for very large screens and some laptops which display ones screen Flat.

Businesses with very large sets of data that need easy access use sets of cartridges with robot arms to pull out the right one on command.This is known as______.

a.
removable hard drives
b.
smart cards
c.
mass storage
d.
USB drives

Answers

Answer:

C. Mass Storage

if incorrect then:

A. Removable Hard Drives

explain how the organ systems work together to warm up the body on a cold day

Answers

Answer:

Your body is to cold ,blood vessels in the skin contract , and blood flow to the extremities (arms and legs)slows . muscles contract and relax rapidly which generates  heat to keep you warm..

Explanation:

Hope this helps :)

Answer:

Sample Response: The brain, through the nervous system, sends signals to the muscular system, causing the muscles to move rapidly. This rapid motion produces heat in the body and is observed as shivering. The brain also sends signals to the muscles right beneath the skin. These muscles shorten and tighten, causing the hairs on the skin to stand up. When the hairs stand up, heat is kept in the air trapped within the hairs, which keeps the body warm.

Explanation:

Sam needs to create a spreadsheet for his coworkers. They will need to follow across a long row of data. Sam would like to make his spreadsheet easy to read. Sam should _____.

Answers

Complete Question:

Sam needs to create a spreadsheet for his coworkers. They will need to follow across a long row of data. Sam would like to make his spreadsheet easy to read. Sam should _____.

Group of answer choices

A. make some formatting changes such as adding a fill color to every other row.

B. change the text color to light green and change the fill color to red.

C. leave the spreadsheet without any format changes.

D. highlight the cells.  

Answer:

A. make some formatting changes such as adding a fill color to every other row.

Explanation:

A spreadsheet can be defined as a file or document which comprises of cells in a tabulated format (rows and columns) typically used for formatting, arranging, analyzing, storing, calculating and sorting data on computer systems.

Some examples of spreadsheet software applications are Microsoft Excel, Lotus symphony, iWork numbers, Google sheets etc.

In this scenario, Sam needs to create a spreadsheet for his coworkers. They will need to follow across a long row of data with informations such as name, age, gender, education, experience, address, date of birth, nationality, relationship status etc. Also, Sam would like to make his spreadsheet easy to read.

Hence, Sam should make some formatting changes such as adding a fill color to every other row by selecting the preferred row and choosing a specific color that he wants such as red, white, green, blue, yellow etc.

Basically, formatting a spreadsheet with different colors makes it easy to read and enhances quick location of specific information in the spreadsheet by the end users.

write a paragraph about ICT?

Answers

Answer:

ICT (information and communications technology or technologies) is an umbrella term. It includes any communication device or application, such as radio, television, cellular phones, computer and internet, satellite systems and so on. Videoconferencing and distance learning is a very important part of ICT.

can someone please explain binary addition to me? i have a test tomorrow yikes

Answers

Answer:

its easy

Explanation:

there are are 5 main rules

in binary there are 2 number 0 and 1

0 + 0 = 0

0 + 1 = 1

1+0=1

1+1=0 carry 1

e . g

1 1 1

1 0 1 0 1 0

+ 1 1 0 0 1 0

-------------------------

1 1 1 1 1 0 0

*in bold are the ones that you need to carry.

in decimal there are 10 possible numbers 0- 9

when you do 1 + 9 it becomes 10, this can be done easily, however if you do 1 + 9 in a table like above, you will get 0 for the first column and you will carry 1 to the next column .

in binary is the same idea but using on 2 numbers 1 and 0

e.g

1

1

+ 9

----------

1 0

*in bold are the ones that you need to carry.

hope it helps and good luck in your exam.

What is the purpose of i in the code?

for (var i = 0; i < fruitList.length; i++ ) {
console.log (fruitList [ i ] );
}

Answers

Answer:

i is a variable used to store information in this case the number 0. The i is then added to repeatedly to create a list.

What am I doing wrong?

Answers

In your example, you're asking the user for a number and then you're setting total and nums equal to zero. This results in your first number being ignored by the program. I included the complete working code below:

num = int(input("Enter a number: "))

total = num

nums = 1

while (total <= 100):

   num = int(input("Enter a number: "))

   nums = nums + 1

   total = total + num

print("Sum: "+str(total))

print("Numbers Entered: "+str(nums))

I hope this helps!

Identify 5 way computer are used in weather forecasting an traffic control​

Answers

Answer:

Computers are used for interpolating data, and analyzing very complicated data.

Explanation:

In forecasting we need to look at a lot of weather variables (temperature, dew point, pressure and wind speed to name a few). We only collect this data from weather observation sites which can be tens to hundreds of kilometers apart. In order to determine these values at locations between the observation sites we interpolate.

When you are forecasting you need look at a lot of data and determine what is going on to determine what is going to happen next. If humans did all the interpolating themselves for all the data they would never be able to issue the forecast in the time that is expected. Furthermore, now that we have very complicated values to analyze (vorticity for example) there is no way that a human can calculate the effect of all the various factors in play. A computer has to do it.

Computers are also required for using weather radar, and yes to a lesser extent satellite data.

Discuss one simple example of hybrid computer.​

Answers

Answer:

thermometer , petrol pump

What will be displayed in the console when the following program runs?

var count = 0
while (count != 5){
console.log(count);
count = count + 2;
}

Answers

Answer:

The integer, count, will be stuck in a infinite while loop, and the console will keep adding 2 to count, so it'll look something like this.

0

2

4

6

8

10

12

14

and so forth...

Explanation:

The while loop will never stop because count can not equal to 5 because you can't add 2 to another multiple of 2 to get 5.

Because count cannot reach 5, and you cannot add 2 to another multiple of 2, the while loop will never come to an end.

What displayed in the console when program runs?

An endless loop is a section of code that never reaches the ending condition, hence it keeps running indefinitely. An infinite loop may cause your software or browser to crash or freeze. Infinite loops must be understood in order to avoid such situations.

When a condition always evaluates to true, an infinite loop happens. Typically, this is a mistake. You may, for instance, have a loop that decreases until it hits zero.

Therefore, It will resemble this because the integer count will be locked in an unending while loop and the console will keep adding 2 to count. 0, 2,4, 6, 8, 10,12, 14 The program will end in an infinite loop.

Learn more about program runs here:

https://brainly.com/question/19339163

#SPJ2

I need help please !!!!

Answers

Answer:

Second one

Explanation:

evaluation of ur problems

Where do high tides occur? (Select two.)
WILL GIVE BRANLEST PLS ASAP

only at the South Pole

on the side of Earth opposite the moon

on the side of the Earth facing the moon

only at the North Pole

at both the North and South Poles

Answers

Answer: The Moon's gravitational pull generates something called the tidal force. The tidal force causes Earth—and its water—to bulge out on the side closest to the Moon and the side farthest from the Moon. These bulges of water are high tides. High tide (left) and low tide (right) in the Bay of Fundy in Canada.

Explanation:

So the two I think will be 1. On the side of the earth facing the moon and I think both south and North Pole

What is the purpose of the introduction in an expository essay? A. to introduce the author and his or her dedication B. to highlight the main points of the essay C. to describe the supporting details D. to provide a figurative interpretation of the essay

Answers

I think it’s B, sorry if I’m wrong with this >

Identify the type of data for each value below.
12.023
"Hello World
52

Answers

12.023 is float

"Hello World" is string

52 is int

Your teacher is nice. She/He has given it in the order.

The type of data for 12.023 is a float, "Hello World is a string, and 52 is a int.

What are the type of data?

The  type of data in computer science can be given as the data values that helps in the analysis of the type of operation that is to be performed. The data types in python are given as classes.

The type of data type is:

The point numbers are given as floating. Hence, 12.023 is a float.

The text form is given as string or str data type. Hence, "Hello World is a string.

The whole numbers positive or negative are given as integers or int. Hence, 52 is a int.

Learn more about data type, here:

https://brainly.com/question/22574321

#SPJ2

_____moves the head to proper track

a.
Seek
b.
Data transfer
c.
Rotate
d.
Settle

Answers

to what it seems like the answer would be C
i believe the answer is C

What can you add to your presentation from the Insert tab?

Animations
Pictures
Variants
Transitions

Answers

Answer:

B. PICTURES

Explanation:

Answer:

I know its late but pictures is the answer.

Explanation:

I took the test and got it right.

I don't understand how to do these. It's python by the way.

Answers

Answer:

Disclaimer: I dont put the Euler, magic word, and another variables, you need to do this

Explanation:

print(eulersNumber[16])

print(eulersNumber[26])

print(eulersNumber[31])

print(magicWords[:3]+magicWords[8:10])

3° I dont know how i can make this

print(a[::-1])

print(b[::-1])

print(c[::-1])

print(x[::-1])

print(y[::-1])

Have a nice day

Which Python expression results in 49?

7 * 2

7^2

7 // 2

7 ** 2

Answers

Answer:

7^2

Explanation:

7^2 is the same as 7*7

Answer:

7^2 ( ^ ) this sign help us

Write a function named last_digit that returns the last digit of an integer. For example, last_digit(3572) should return 2. It should work for negative numbers as well; last_digit(-947) should return 7.

Answers

def last_digit(num):

   num = str(num)

   return int(num[-1])

print(last_digit(-947))

I hope this helps!

Which of these should be included in a program's comments?

a. code to set the parameters of a shape

b. a description of what the program does

c. a description of how long it took to write the code

d. code for inserting a background

Answers

Answer:

B

Explanation:

Comments in code are primarily used to describe what the program does, and how chunks of the code running the program help relate to what the program does. Comments in code are not primarily used for answers d & a, which is more code, since if you comment, the compiler doesn't notice the code, so it doesn't work. Comments in code are not used for c either, since it's not really needed to write that in the comments.

What does a network backbone do?
allows data to be delivered more quickly and efficiently
makes data transfer from the cloud more secure
connects different network functions, such as printers and modems
configures random local networks in major cities that make up the Internet

Answers

Answer:

configures random local networks in major cities that make up the internet.

Answer:

D

Explanation:

which of these options highlights the need for learning algorithms
A. Algorithms help you draw neat diagrams
B. Algorithms help you create easily understandable programs
C. Algorithms help you learn assembly-level language
D. Programmers can code using algorithms only

Answers

Answer: D.

Explanation:

Answer:

The answer is B. Algorithms help you create easily understandable programs

Explanation:

I got it right

Other Questions
i really need help with this Which of the following statements about the urbanization of early civilizations is true?A. Early civilizations tended to take two main forms: nomadic tent dwellers and semi-nomadicherders, both of which existed in the desert and semiarid regions.B. Early civilizations settled in coastal areas because oceanic trade and sea travel were importantmeans of acquiring resources.C. Most early civilizations were located in cooler climates, which supported bigger game hunting,herding, and gathering.D. Early civilizations settled along river valleys because the proximity to water and food sourcessupported greater populations. What colonial reaction to the Townshend Acts was most harmful to Britain? Which expression is equivalent to 735 100?7.35 1000 735 x 0.01735 x 0.00173.5 100 What are the five former state capitals for Georgia in order Without(blank)a species is not able to survive.A. geneticsB. reproductionC. kingdomsD. bacteria The sky is low, the clouds are mean,A travelling flake of snowAcross a barn or through a rutDebates if it will go.A narrow wind complains all dayHow some one treated him;Nature, like us, is sometimes caughtWithout her diadem.Read the poem "The Sky is Low, the Clouds are Mean", and answer the question that follows.What effect is created by the pauses at the end of lines two, four, six, and eight in this poem? How is this effect connected to the larger impact of the poem? Your response should be no less than 150 words.Pls answer this 35 points to answer,pls don't put idk or anything like that.this test is worth 40 percent of my grade.pls and thank you. Which one is NOT true about chemical changes? * The typical colonial view towards the executive power could be best described as one of....A.unquestioning loyaltyB.admirationC. gratitudeD.mistrust Please help its urgent!!! For these 2 questions Harry is in disbelief because he thinks... What is the answer to this? I think its the one I selected but I want to verify There are some nickles,dimes and quarters in a large piggy bank.For every 2 nickles there are 3 dimes.For every 2 dimes there are 5 quarters.There are 500 coins total.How many Nickles,Dimes and Quarters are in the piggy bank? [tex]\frac{m}{y}=gh\\solve for m[/tex] If you want to buy an item in a store that costs $32.50 and is on sale for 30% off, then how much would the item actually cost you after the discount? Round to the nearest cent. You runcompletely around a 400m track in100s. What was your average velocity? The general vision pattern which users reading text-heavy websites will follow, first scanning horizontally across the top line of the content and then shifting focus downwards slightly and again scan horizontally across the text, and finally scanning vertically down the left side is known asGroup of answer choicesa. Recitingb. Skimmingc. F-pattern readingd. Scanning Milk contains sugar, fat and water. It is a mixture because A. It retains the individual property B. It has a high boiling temperature C. It is homogeneous mixture D. They are all substances In the Bohr model of the hydrogen atom, an electron in the 1st excited state moves at a speed of 2.19 106 m/s in a circular path having a radius of 5.29 10-11 m. What is the effective current associated with this orbiting electron? With a little help from her friends, Brigitte finds a new room. Create a question, using all elements of the originalstatement and qui or qui, that corresponds to the item of information in italics.MODLE: Brigitte cherche un logement.Qui cherche un logement?Please help?!