PYTHON
1. Using floating-point numbers can lead to arithmetic errors because floating-point numbers
a. |
require the use of exponents |
b. |
are approximate values |
c. |
can’t be used in expressions with integers |
d. |
usually don’t have enough significant digits |
ANS:
2. Which of the following will produce the same result as this code?
import math as m
area = m.pi * radius**2
a. |
area = m.pi * pow(radius) |
b. |
area = m.pi * m.pow(radius) |
c. |
area = m.pi * pow(radius, 2)) |
d. |
area = m.pi * m.pow(radius, 2) |
ANS:
3. What will be displayed when this code is executed?
name = "Name"
ID = "ID"
print("{:10} {:>5}".format(name, ID))
print("{:10} {:7d}".format("Liz", 234))
print("{:10} {:7d}".format("Mike", 23456))
a. |
Name ID Liz 234 Mike 23456 |
c. |
Name ID Liz 234 Mike 23456 |
b. |
Name ID Liz 234 Mike 23456 |
d. |
Name ID Liz 234 Mike 23456 |
ANS:
1. are approximate values 2. area = m.pi * m.pow(radius, 2) 3 Name ID Liz 234 Mike 23456
PYTHON 1. Using floating-point numbers can lead to arithmetic errors because floating-point numbers a. require the...
Python, given a code in class i just need help with the third bullet point ; using a and n (defined in the second picture of python code) find the first digit for k! for k =1,...,n. you dont have to type in all this code just help me write the code in the first picture where it says: def benford(a): b = [0 for d in range(1,10)] #Do everthything in here return b 2.2 Generating data In this assignment...
Need to solve this program which will run exactly like sample run .. Thanks Project 2 Using Classes and Objects (Chapter 3) Duc: sec calendar Two files to be submitted: . Algorithm of method main (AlgorithmOfMain.txt, no credit if this is missing) Java Source code (CarpetBill.java- no credit if this has syntax errors) Write a program that creates customers' bills for a carpet company when the information below is given: irst name .Length and width of the carpet in feet...
Designing functions Reminder: When designing functions, follow the given steps to reinforce good software development practices and problem solving strategies: a) Start by writing the documentation for the function. Use docstrings shown in lecture and lab. b) Write test calls to the function in your main function for the different cases of input the function will encounter. This will help you understand the behavior of the function and later behave as tests for your function. c) Define the function d)...
Lab 1.java only Goal: This lab will give you experience with defining and using classes and fields, and with conditionals and recursive functions. Getting Started --------------- Read the Fraction.java class into a text editor and compile it filling in the command javac -g Fraction.java. The program should compile without errors. In a shell window, run the program using "java Fraction". The program should run, although it will print fractions in a non-reduced form, like 12/20. Part I: Constructors (1 point)...
You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...