Question

this is in python 3.6

Write a program that prints to three significant figures the values of x and g(x) from x = 0 to x = 10 in increments of 2 units.

The values of x include 0 and 10.

The function g(x) is defined below:

g(x): sqrt(x); x<4

sqrt(4); 4<=x

The output of the first and last values are below:

0.000 0.000

... ...

10.000 2.000

Answer #1

code:

import math

# funtion g(x) returns sqrt(x) when x<4 and returns
4<=x

def g(x):

if x<4:

# return sqrt(x)

return math.sqrt(x)

else:

# return sqrt(4)

return math.sqrt(4)

# for x = 0 to x = 10

for x in range(11):

print("{0:.4f} {1:.4f}".format(x,g(x)))

screenshot:

output:

//follow the screenshot of code for the indentation of the program

//if you like the answer please give an upvote and for any queries ask in comment

Write a Python program prints out the unique elements of a list
lst in a sorted manner (i.e it removes duplicates from the list).
For example, if list is [10,20,30,20,10,50,60,40,80,50,40], the
output should be [10, 20, 30, 40, 50, 60, 80].?

PYTHON 3
Write a program that prints the count of all prime numbers
between A and B (inclusive), where A and B are defined as
follows:
A = 21212
B = A + 5000
Just a recap on prime numbers: A prime number is any number,
greater or equal to 2, that is divisible ONLY by 1 and itself. Here
are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and
29.
Rules:
You should first...

In Python:
Problem 4. Write a program [call it minmax.py] that accepts three integers in the range [0-100] as input from the user. Your program should then determine and print the smallest and largest integers in the values entered by the user using comparison operators *not* using predefined min or max Python functions.
For instance:
If the user input is: 36 5 99 your program should give as output: min = 5 max = 99
If the user input is:...

Write a Python program that reads in the month, day, and year
of a date and prints it in the
dd/mm/yyyy format or mm/dd/yyyy format, the format depending
on the user’s preference. The
program also prints the message
It is a magic date
If the product of month and day is equal to the last two
digits of the year. For example, April 20
1980 is a magic date because April (numeric value 4)
multiplied by 20 is equal to...

Write a python program that does the
following:
Prompts the user for three numbers in one request.
Be sure to specify the “delimiter” by which a user enters those
three numbers.
Divides the first number by the second number and add that result
to the third number.
Prints output that shows in one line the formula applied and the
result of the calculation.
Validate input by:
• Checking the user
entered 3 values
• Appropriately
checking for the following errors:...

write a program in python for following
x = { 'a' : 1 , 'b':2 , 'c':3, 'd':4 }
For the following key,value pairs of dictionary display those
which are even values i.e for which the value is even.
i am trying like this but getting confused.
(k:v for k,v in x.items() if v%2 != 0

Write a program that does the following and prints out
the result
Use a
do-while loop and switch statement
Enter
value x and a case number n
for n =
0 exit else continue
n=100
result = x * 9
n=102
result = x + 10 and continue
n=103
result = (x + 10) * x
n=104
and 106 result = x / x
default result = 99;
test with x =...

Write spim program and execute it on mars. Your program reads
two integer values x and y. Write a function called sum that gets x
and y passed as parameters and return the sum of odd values between
x and y inclusive. In addition write another function called even
that gets x and y as parameters and returns the count of all even
numbers between x and y inclusive. Also in main print the quotient
and remainder of diving y...

TO BE DONE IN PYTHON: Write a function `lowest_integer()` which
takes 2 input arguments:
1)a function `g` representing an increasing function
g(x)
2) a number `gmin`,
and returns an integer `nmin` such that
nmin>0
is the smallest integer that satisfies
g(nmin)>gmin.
test:
def g(n):
return 2*n
print(lowest_integer(g, 10))
Output: 6

write a python program that include a function named
activity_selection() and take in two arguments, first one would be
the number of tasks and the second argument would be a list of
activities. Each activity would have an activity number, start time
and finish time.
Example activity_selection input and output:
activity_selection (11, [[1, 1, 4 ], [2, 3, 5], [3, 0, 6], [4,
5, 7], [5, 3, 9], [6, 5, 9],[7, 6, 10], [ 8, 8, 11], [ 9, 8,...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 5 minutes ago

asked 25 minutes ago

asked 28 minutes ago

asked 57 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago