Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 3, Problem 6D
Explanation of Solution
a)
Given statement: -10 // 3
#Define the main function
def main():
#Calculate the value of x
x = -10//3
#Print ...
Explanation of Solution
b)
Given statement: -10 % 3
Program:
#Define the main function
def main():
#Calculate the value of x
x = -10%3
#Print...
Explanation of Solution
c)
Given statement: 10 // -3
Program:
#Define the main function
def main():
#Calculate the value of x
x = 10//-3
#Print ...
Explanation of Solution
d)
Given statement: 10 % -3
Program:
#Define the main function
def main():
#Calculate the value of x
x = 10%-3
#Print ...
Explanation of Solution
e)
Given statement: -10 // -3
Program:
#Define the main function
def main():
#Calculate the value of x
x = -10//-3
#Print ...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In C++ Just answer the questions in simple code please.
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. Do this in a function called Sierra.
What do you think will happen when the operands to the integer divisionor remainder operations are negative? Consider each of the followingcases and try to predict the result. Then try them out in Python. Hint:Recall the magic formula a= (a/ /b)(b) + (a%b).a)b)c)d)e)-10 II 3-10 % 310 II -310 % -3-10 II -3
In Python,
Compute the: sum of squares total (SST), sum of squares regression (SSR), sum of squares error(SSE),
and the r, R^2 values. You can use the sum() and mean() built-in functions.
Here are the x and y values to use.
x = [-5,-1,3,7,5,10]
y = [-10,-3,5,8,7,10]
Chapter 3 Solutions
Python Programming: An Introduction to Computer Science, 3rd Ed.
Ch. 3 - Prob. 1TFCh. 3 - Prob. 2TFCh. 3 - Prob. 3TFCh. 3 - Prob. 4TFCh. 3 - Prob. 5TFCh. 3 - Prob. 6TFCh. 3 - Prob. 7TFCh. 3 - Prob. 8TFCh. 3 - Prob. 9TFCh. 3 - Prob. 10TF
Ch. 3 - Prob. 1MCCh. 3 - Prob. 2MCCh. 3 - Prob. 3MCCh. 3 - Prob. 4MCCh. 3 - Prob. 5MCCh. 3 - Prob. 6MCCh. 3 - Prob. 7MCCh. 3 - Prob. 8MCCh. 3 - Prob. 9MCCh. 3 - Prob. 10MCCh. 3 - Prob. 1DCh. 3 - Prob. 3DCh. 3 - Prob. 4DCh. 3 - Prob. 6DCh. 3 - Prob. 1PECh. 3 - Prob. 2PECh. 3 - Prob. 3PECh. 3 - Prob. 4PECh. 3 - Prob. 5PECh. 3 - Prob. 6PECh. 3 - Prob. 7PECh. 3 - Prob. 8PECh. 3 - Prob. 9PECh. 3 - Prob. 10PECh. 3 - Prob. 11PECh. 3 - Prob. 12PECh. 3 - Prob. 13PECh. 3 - Prob. 14PECh. 3 - Prob. 15PECh. 3 - Prob. 16PECh. 3 - Prob. 17PE
Knowledge Booster
Similar questions
- Write a C++ program: to iteratively compute Fibonacci numbers (named after an Italian mathematician). Some Fibonacci numbers are 1,1,2,3,5,8,... where the next number is found by summing the preceding two numbers. Your program is not assured of recieving good data, thus if -2 is recieved as the number of numbers, then an error should be reported. Try n = 5, 7, 10, -3arrow_forwardFor each of the following three program fragments:a. Give an analysis of the running time (Big-Oh will do).b. Implement the code in the language of your choice, and give the running time for several values of N (100, 500, 1000, 5000).c. Compare your analysis with the actual running times. (1) sum = 0; for( i = 0; i < n; ++i )++sum; (2) sum = 0; for( i = 0; i < n; ++i ) for( j = 0; j < n * n; ++j ) ++sum;(3) sum = 0; for( i = 0; i < n; ++i ) for( j = 0; j < i * i; ++j ) for( k = 0; k < j; ++k ) ++sum;arrow_forwardWrite a python function that takes one integer (n) parameter and prints the first n digits from the Fibonacci series using recursion.Sample input: 5Sample output: 0, 1, 1, 2, 3 Write a function that takes one integer parameter, makes sure it is an integer, prints sum of every two digits and return the sum of digits from the number entered by the user up to 1, using recursion.Sample input: 4 Sample output: 4+3 = 77+2 = 99+1 = 10arrow_forward
- Write a short C++ or Python program to support your answer (for example, show that you checked whether there is no smaller number than your f by trying 128+f/2 == 128.arrow_forwardWrite the code in Java and C++ ....Given arrival and departure times of all trains that reach a railway station. Find the minimum number of platforms required for the railway station so that no train is kept waiting.Consider that all the trains arrive on the same day and leave on the same day. Arrival and departure time can never be the same for a train but we can have arrival time of one train equal to departure time of the other. At any given instance of time, same platform can not be used for both departure of a train and arrival of another train. In such cases, we need different platforms. Example 1: Input: n = 6 arr[] = {0900, 0940, 0950, 1100, 1500, 1800}dep[] = {0910, 1200, 1120, 1130, 1900, 2000}Output: 3Explanation: Minimum 3 platforms are required to safely arrive and depart all trains.Example 2: Input: n = 3arr[] = {0900, 1100, 1235}dep[] = {1000, 1200, 1240}Output: 1Explanation: Only 1 platform is required to safely manage the arrival and departure of all trains.arrow_forwardWrite a C++ program to compute the following numbers in an "eficient" way: {1,1,2,3,5,8,13,21,...}. Can you also write it in "recursive" way? What is the difference between them?arrow_forward
- Write code in C++, C# or Python to solve the following problem: Instead of a regular Fibonacci number, you are supposed to calculate a special one as follows: F(n) = F(n-1)+ 2 * F(n-2) + 3 * F(n-3) As an example, if F(0) = F(1) = F(2) = 1, then we have: F(3) = F(2) + 2 * F(1) + 3 * F(0) = 1 + 2 + 3 = 6 F(4) = F(3) + 2 * F(2) + 3 * F(1) = 6 + 2 + 3 = 11 Given F(0), F(1), F(2), and N, your job is to calculate F(N). Input Format First number is F(0), second number is F(1), third number is F(2), and last number is N. Example input: 1 1 1 4 Constraints NA Output Format Print the Nth special Fibonnaci number. Example output: 11 Sample Input 0 1 1 1 4 Sample Output 0 11arrow_forwardWrite a C++ program to implement a calculator with the following features: Exponentiation, Logarithm, Sine and Cosine (input angle in degrees). Choose the code 'E' for exp, 'L' for log10, 'l' for log base e, 'S' for sin, 'C' for cosinearrow_forwardWrite in c language please, The Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the previous two, for example: 0, 1, 1, 2, 3, 5, 8, 13. Complete the Fibonacci() function, which has an index n as a parameter and returns the nth value in the sequence. Any negative index values should return -1. Ex: If the input is: 7 the output is: Fibonacci(7) is 13 Note: Use a for loop and DO NOT use recursion.arrow_forward
- Write a program in C to compute the roots of a quadratic equation (ax² + bx + c = 0). The roots of the equation can be calculated using the following formulae: x1 = (-b + sqrt(b? – 4ac))/2a x2 = (-b – sqrt(b? - 4ac ))/2a Note: If b? – 4ac is negative, the roots are complex. Write your program in the space provided. Using text editor, type and save your program. Test your program to solve the following equations: (a) x + 2x – 15 = 0 (b) 4x +x+3 =0 (c) x? – 8x + 16 = 0 (d) 7x – 5 = 0 Use CodeBlocks. Take a picture of the code and results. A flow chart to solve the problem is shown below. Start Input a,b,c True a -- 0 False X = -/b disc = b2 - 4ac Print Not a Quadratic Equation Print x False True disc --0 False X = -b/2a X = -b/2a disc >0 True ximg, - sort(disc)/2a ximag, - sgrt(disc)/2a xr = -b/(2*a) X - (-b + sgrt(disc)/2a X, - (-b - sart(disc) y2a Print x, X2 Print x, X Print xr, ximg, ximg Stoparrow_forwardIN PYTHON, Using recursion: ask the user for the length of a square and the character they want to use. Draw the square (similar to mini assignment #15 in functions part 3). Once the user creates the square with their specification, ask them if they want it to be smaller or larger and how many times. Draw all the squares growing in size to the specified range.arrow_forwardalthough java has the rule that the left operand of every binary operator is evaluated before the right operand, most languages give the compiler the freedom to choose which operand is evaluated first. when expressions have side effects, the value of the expression can be different depending upon which order is used. give an example in c++ of an expression whose value depends upon the evaluation order. show the orders that produce different values and the values they produce. explain what side effect is the expression contains.(dont copy and coursehero ans please) need elaborative ansarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education