DATA PROGRAMMING: PYTHON
Be sure to use sys.argv NOT input.
Write a program and create a function called inch2cm that takes one
number in inches as a parameter, converts it to the centimeters and
prints the result. The program output is shown below.
Input: 14
Output:
14 inches = 35.56 centimeter
Write a program and create the following functions:
shapes(): takes the shape name and a number as parameters, and
calls the proper function to calculate the area.
areaCircle(): take one number as a parameter, calculates the area
of the circle, and print the result. Round the output to 2 decimal
places.
areaSquare(): takes one number as a parameter, calculates the area
of the circle, and prints the result. Round the output to 2 decimal
places.
You can assume the shape names will be circle or square (nothing
else). The program output is shown below.
Input:
10
5
Output:
a) The circle area is 314.16
b) The square are is 25
Write a program and create a function called isOdd that takes a
number and determine it is an odd number or not. The program output
is shown below.
Input:
9
10
Output:
a) 9 is an odd number
b) 10 is not an odd number
Write a program and create a function called calc. The function
generates a random integer number between 10 and 100, and
determines it is divisible y 6 or not, and prints the result. The
output is shown below.
Output:
a) 55 is not divisible by 6
b) 72 is divisble by 6
1)ans..
CODE:
import sys
def inch2cm(n):
print("{0} inches = {1}".format(n,2.54*n),"
centimeter")
input = sys.argv[1]
inch2cm(int(input))

2)
CODE:
import sys
import math
def areaCircle(r):
print("The circle are is ",round(math.pi*r**2,2))
def areaSquare(r):
print("The square area is",round(r*r,2))
def shape(name,r):
if(name=="circle"):
areaCircle(r)
else:
areaSquare(r)
r = sys.argv[1]
s =sys.argv[2]
shape("circle",int(r))
shape("square",int(s))
3)ans..
CODE:
import sys
def isOdd(n):
if n%2!=0:
print("{0} is an odd
number".format(n))
else:
print("{0} is not an odd
number".format(n))
input = sys.argv[1]
isOdd(int(input))

4)
CODE:
import random
def calc():
r = random.randrange(10, 100)
if r%6==0:
print(r," is divisible by 6")
else:
print(r," is not divisible by
6")
calc()
OUTPUT:

If you have any doubts please COMMENT...
If you understand the answer please give THUMBS UP..
DATA PROGRAMMING: PYTHON Be sure to use sys.argv NOT input. Write a program and create a...
PYTHON PROGRAMMING: DO NOT USE INPUT FUNCTION, use sys.argv (PLEASE TYPE OUT ANSWER) Modify this program: Write a program to calculate the bmi getcategory(): takes the bmi as a parameter and returns the bmi category. You are not allowed to change the two functions and you will use the same two functions as previously. Just modify the program so that it calculates the bmi and category for any number of pairs of height and weights. You must loop through the...
Data Programming l: Python Write a program that calculates how much Mary should pay for buying 3 KitKat each worth $2 and 2 Twix chocolate each worth $4. Output: Mary should pay $14. Write a program that takes the circle radius and compute the circle area. Use the round function to have at most 2 decimal places in the output. Output: The area of a circle with 4 inches radius is 50.27
PYTHON PROGRAMMING: DO NOT USE INPUT FUNCTION, use sys.argv Write a program that generates two random integer numbers between 1 and 100. Then, print out the numbers between the two randomly generated ones using a while loop. The output is shown below. Output: a) start:4, end:14 4 5 6 7 8 9 10 11 12 13 14 b) start:15, end:20 15 16 17 18 19 20
Write a complete program that uses the functions listed below. Except for the printOdd function, main should print the results after each function call to a file. Be sure to declare all necessary variables to properly call each function. Pay attention to the order of your function calls. Be sure to read in data from the input file. Using the input file provided, run your program to generate an output file. Upload the output file your program generates. •Write a...
How to solve it using Python?
5. Write a function called no_squares which takes an input parameter N, a positive integer, and returns: 1 if N is not divisible by a square and has an even number of prime factors -1 if N is not divisible by a square and has an odd number of prime factors 0 if N is divisible by a square For example, no-squares (10) returns 1 (since 10 = 2x5), no-squares (30) returns-1 (since 30...
Is Prime Number In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter a positive integer, and outputs a message indicating whether the integer is a prime number. If the user enters a negative integer, output an error message. isPrime Create a function called isPrime that contains one integer parameter, and returns a boolean result. If the integer input is a prime number, then this function returns...
Use C programming
Make sure everything works well only upload
Write a program that takes an integer from standard input and prints all prime numbers that are smaller than it to standard output. Recall that a prime number is a natural number greater than 1 whose only positive divisors are 1 and itself. At the start of the program, prompt the user to input a number by printing "Input a number greater than 2:\n". If the user's input is less...
Use PYTHON3 to create a program that asks the user for their name, and then prints their initials. You must create a function called getInitials() that takes the name string and prints out the initials. It must be case insensitive and the initials must be printed in upper case. The program must contain a main() and a function called getInitials(), implemented as described in the function header comment given below. (You should include this function header comment in your own...
1. Write a program that takes a number as input and check whether the number is positive, negative or zero. 2. Write a C++ program that prompts the user to enter a number and checks whether the entered number is even or odd. 3. Using switch-case statement write a C++ program that prompts the user to enter 1, 2 or 3 and display "Red" if selection is 1, "Yellow" if selection is 2, or "Green" if selection is 3. 4. Write...
The program will need to accept two input arguments: the path of the input file and the path of the output file. See etc/cpp/example.ifstream.cpp for the basis of how to do this. Once the input and output file paths have been received, the program will need to open the input and output files, read and process each input file line and create a corresponding output file line, close the input and output files, and then create and output some summary...