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
Vadim26 [7]
3 years ago
6

Write a function named is_float(s) that takes one argument that is a string. It returns True if string s represents a floating p

oint value and returns False otherwise. You are required to use try-except. The basic concept is to "try" to convert string s to a float and if it succeeds, return True, but if it fails (that is, an exception is raised), return False. Note that float() raises a ValueError exception.
Engineering
1 answer:
Vedmedyk [2.9K]3 years ago
8 0

Answer:

Explanation:

# Python Programme

#!/usr/bin/python

# Function definition is here

def is_float( str ):

try:

float(str)

return True

except ValueError:

return False

# Now you can call is_float function

print(is_float("3.45"))

print(is_float("3e4"))

print(is_float("abc"))

print(is_float("4"))

print(is_float(".5"))

You might be interested in
Write a function called largest3 which takes 3 numbers as parameters and returns the largest of the 3. Write a program which tak
tamaranim1 [39]

Answer:

The solution code is written in Python.

  1. def largest3(num1, num2, num3):
  2.    largest = num1
  3.    if(largest < num2):
  4.        largest = num2
  5.    
  6.    if(largest < num3):
  7.        largest = num3
  8.    
  9.    return largest
  10. first_num = int(input("Enter first number: "))
  11. second_num = int(input("Enter second number: "))
  12. third_num = int(input("Enter third number: "))
  13. largest_number = largest3(first_num, second_num, third_num)
  14. print("The largest number is " + str(largest_number))

Explanation:

<u>Create function largest3</u>

  • Firstly, we can create a function <em>largest3 </em>which take 3 numbers (<em>num1, num2, num3</em>) as input. (Line 1).
  • Please note Python uses keyword <em>def </em>to denote a function. The code from Line 2 - 10 are function body of <em>largest3</em>.
  • Within the function body, create a variable,<em> largest</em>, to store the largest number. In the first beginning, just tentatively assign<em> num1 </em>to<em> largest</em>. (Line 2)
  • Next, proceed to check if the current "<em>largest</em>" value smaller than the<em> num2 </em>(Line 4). If so, replace the original value of largest variable with <em>num2</em> (Line 5).
  • Repeat the similar comparison procedure to<em> </em><em>num3</em> (Line 7-8)
  • At the end, return the final value of "<em>largest</em>" as output

<u>Get User Input</u>

  • Prompt use input for three numbers (Line 13 -15) using Python built-in <em>input</em> function.
  • Please note the input parts of codes is done outside of the function <em>largest3</em>.

<u>Call function to get largest number and display</u>

  • We can simply call the function<em> largest </em>by writing the function name <em>largest</em> and passing the three user input into the parenthesis as arguments. (Line 17)
  • The function <em>largest </em>will operate on the three arguments and return the output to the variable <em>largest_number</em>.
  • Lastly, print the output using Python built-in <em>print</em> function. (Line 18)
  • Please note the output parts of codes is also done outside of the function<em> largest3</em>.
6 0
3 years ago
The system is initially moving with the cable taut, the 15-kg block moving down the rough incline with a speed of 0.080 m/s, and
garik1379 [7]

Solution :

The spring is expanded by 2 times of the block when it moves down an inclined by x times.

Here, $x_1$ = 39 mm

        x_2 = 225 mm

a). From the work energy principal,

   Work forces = kinetic energy

$(mg \sin 50^\circ)\times \frac{99}{1000}-(\mu_k mg \cos 50^\circ) \times \frac{99}{1000} -\frac{1}{2}k(0.225^2 - 0.039^2)=\frac{1}{2}m(V^2_2-0.08^2)$

$(112.6 \times 0.099)-(14.17 \times 0.099)-4.91= 7.5(V^2_2-0.08^2)$

$9.75= 7.5(V^2_2-0.08^2)$

$1.3= V^2_2-0.08^2$

$V_2=1.14\ m/s$

b). calculating the distance travelled by the block before it comes to rest.

Substitute the value of V_2 in (1),

$-(\mu_kmg \cos 50^\circ)x + (mg \sin 50^\circ)x-\frac{1}{2}k\left( ( 2x+0.039)^2 - 0.039^2\right)= -\frac{1}{2}m(0.08)^2$

$-14.17x+112.6x - 100(4x^2+0.156x)=-0.048$

$98.43x - 100(4x^2+0.156x)+0.048=0$

$98.43x - 400x^2-15.6x+0.048=0$

$82.83x - 400x^2+0.048=0$

$  400x^2- 82.83x-0.048=0$

x = 0.20 m

4 0
3 years ago
Can the MOXIE created by NASA be used on earth
Alisiya [41]

Answer:

MOXIE is designed to generate up to 10 grams of oxygen per hour. This technology demonstration was designed to ensure the instrument survived the launch from Earth, a nearly seven-month journey through deep space, and touchdown with Perseverance on Feb

4 0
3 years ago
Please dimension this, was due yesterday.
lorasvet [3.4K]
Love the image isn’t showing up. Try reposting it!
6 0
3 years ago
Which of the following identifies a criterion needed to become a civil engineer?
puteri [66]
I think the answer is the third option
4 0
3 years ago
Other questions:
  • Assume that in orthogonal cutting the rake angle is 15° and the coefficient of friction is 0.15. a. Determine the percentage cha
    14·1 answer
  • A field sample of an unconfined aquifer is packed in a test cylinder. The length and diameter of the cylinder are 50 cm and 6 cm
    9·1 answer
  • Under EPA's regulations, which of the following methods can be used to pressurize an R11 or R123 system for the purpose of openi
    11·1 answer
  • A cylindrical specimen of some metal alloy having an elastic modulus of 106 GPa and an original cross-sectional diameter of 3.9
    5·1 answer
  • Determine the wattmeter reading when it is connected to resistor load.​
    11·1 answer
  • Omg I just got 17/25 questions wrong using this on an Ag test , but got 100’s every time on health
    6·2 answers
  • One year, Boulder receives an unusually high amount of rain during the spring months. How might this event affect the likelihood
    15·1 answer
  • Act as food engineers or biomedical engineers and write a short paragraph explaining why they need to know about mixtures and so
    11·1 answer
  • How do guest room hotel smoke alarms work and differ then regular home versions?
    10·2 answers
  • The on-board computer controls the suspension system based on inputs from?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!