In Python:
import math
from fractions import Fraction
kg = (print(int(input("Enter the avg male mass of your marsupial: "))))
def func1 (kg):
result = (math.sqrt(math.sqrt(kg))) * math.sqrt(kg)
return result
def func2 (kg):
result = (6.3552 * kg) + 1.8751
return result
print(func1(kg))
print(func2(kg))
The def works for only when an actual number is in place, not when using the user variable input. How do I fix this?
import math
kg = int(input("Enter the avg male mass of your marsupial: ")) #
You just need to change this line
def func1 (kg):
result = (math.sqrt(math.sqrt(kg))) * math.sqrt(kg)
return result
def func2 (kg):
result = (6.3552 * kg) + 1.8751
return result
print(func1(kg))
print(func2(kg))

In Python: import math from fractions import Fraction kg = (print(int(input("Enter the avg male mass of...
IN PYTHON ''' Helper func 3: checksum_ISBN Input: a list with 9 single digit number in it (first 9 digit in ISBN) Output: print out: "The correct checksum digit is:__. Now we have a legit ISBN: _____" Hint: just loop through 0-9, test every one with helper func1 to find out the one checksum that forms a legit ISBN with the correct ISBN in lis (10 numbers), call helper func2 to format it correctly. Then print the final result. '''...
You may import the following library functions in your module: from fractions import gcd from math import log from math import floor 'You may also use: • the built-in pow() function to compute modular exponents efficiently (i.e., ak mod n can be written in Python as pow(a,k,n)), You may also need to import your hw3 (will be attached below) 5. Implement a function makePrime(d) that takes a single integer argument d where d >= 1 and returns a probably prime...
PYTHON import random # VARIABLES first_num = random.randint(1, 100) sec_num = random.randint(1, 100) totalsum = first_num + sec_num def additon(first_num, sec_num): return first_num + sec_num; # INTRO print("Hello, \n" "this is an app that helps you practice your math skills while generating 6 sets of lucky numbers") question = input('Are you up for a challenge? [Y/N]') if question == 'n': print('okay, see you later') if question == 'y': print("Let's start!!") # USER NAME VALUE uname = input('what is your user...
Hello, In Python Enhance the prior assignment by doing the following 1) Create a class that contain all prior functions MyLib # This function adds two numbers def addition(a, b): return a + b # This function subtracts two numbers def subtraction(a, b): return a - b # This function multiplies two numbers def multiplication(a, b): return a * b # This function divides two numbers # The ZeroDivisionError exception is raised when division or modulo by zero takes place...
Intro to Python:
Q1:
Bonnie is writing a Python program for her math class so she can
check her answers quickly. She is having some difficulties,
however, because when she enters values like 3.5 or 2.71 her
program throws an error. She has heard of your expertise in Python
and asks for your help. What error is being thrown and how can she
fix the program to accept values like 3.5 or 2.71?
from math import sgrt def distance (coorl,...
This problem demonstrates the use of import module. The Python programming language has many strengths, but one of its best is the availability to use many existing modules for various tasks, and you do not need to be an experienced computer programmer to start using these modules. We have given you some incomplete code; note that the very first line of that code contains an import statement as follows: import math This statement enables your program to use a math...
Can you please enter this python program code into an IPO Chart? import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the non-numbers #if user enters letters, then except will show the message, Numbers only! try: c=int(input("Enter your choice: ")) if(c>=1 and c<=3): return c else: print("Enter number between 1 and 3 inclusive.") except: #print exception print("Numbers Only!")...
This is a python question. from urllib import request import json """ Complete this program that calculates conversions between US dollars and other currencies. In your main function, start a loop. In the loop, ask the user what currency code they would like to convert to And, how many dollars they want to convert. If you scroll down, you can see an example response with the available 3-letter currency codes. Call the get_exchange_rates() function. This function returns a dictionary with...
Copy the following Python fuction discussed in class into your file: from random import * def makeRandomList(size, bound): a = [] for i in range(size): a.append(randint(0, bound)) return a a. Rename the function sumList as meanList and modify it so that it finds the average of the list. The average is the sum divided by the size (len) of the list. Make sure that the function doesn't give you an error when it is called on an empty list. The...
This is a python question. Start with this program, import json from urllib import request def main(): to_continue = 'Yes' while to_continue == 'yes' or to_continue == 'Yes': currency_code = input("Enter currency code: ").upper() dollars = int(input("Enter number of dollar you want to convert: ")) # calling the exchange_rates function data = get_exchange_rates() if currency_code in data["rates"].keys(): currency = data["rates"][currency_code] # printing the the currency value by multiplying the dollars amount. print("The value is:", str(currency * dollars)) else: print("Error: the...