Nobody downloaded yet

Summary

The pixel, or picture element appears to be a visible dot on the screen. However in reality, a pixel is not a square dot, rather it is an abstract sample whose color is defined by the variation in the intensity levels of the RGB (Red, Green, Blue) components or the CYMK (Cyan, Magenta, Yellow, Black) components.…

Read TextPreview

- Subject: Technology
- Type: Essay
- Level: Masters
- Pages: 13 (3250 words)
- Downloads: 0
- Author: terrill94

Save Your Time for More Important Things

Let us write or edit the essay on your topic
"Programming using Python"
with a personal 20% discount.

GRAB THE BEST PAPERProgramming using Python

7. import turtle

import math

turtle.forward(50)

turtle.right(90)

turtle.forward(50)

turtle.right(90)

turtle.forward(50)

turtle.right(90)

turtle.forward(50)

turtle.right(90+45)

turtle.forward (math.sqrt(2*50*50))

turtle.right(90+45)

turtle.forward(50)

turtle.right(90+45)

turtle.forward (math.sqrt(2*50*50))

turtle.left (45)

turtle.left(45)

turtle.forward (math.sqrt(25*50))

turtle.left(90)

turtle.forward (math.sqrt(25*50))

8. save

#!./bday.py

Answers for Section 2.11, Exercises

1. From the given statements (Print 12, print "12"), both the statements would print the value 12, The first statement (print 12) can only print the literal value 12 since variable names cannot begin with a number. However, (print a, print "a") statements would make a difference because 'print a' would print the value of able named 'a'.

2. The literals from the given piece of code are given below, in each line separately.

1

dog

, went to mow a meadow.

man

and his

,

,

and his

3. The output of the given code is exactly as below :

1 man and his dog , went to mow a meadow. 3 man , 2 man , 1 man and his dog , went to mow a meadow.

4. The Python Interpreter would return the output "8" for the input 4+4/2+2 .

5. print (2)

print (5)

print (6)

6. The correct program to convert from dollars to British pounds is given below :

dollars = 10

conv = 1.75

pounds = dollars / conv

print dollars, "USD is ", pounds,"GBP."

7. The below code for example, uses the a modified convert function to convert US Dollars to Indian Rupees.

def convert (USD, conv, target_c):

result = USD * conv

print USD,"dollars is ",result,target_c

convert (50,...

The best looking spirals however, are those with only a small change in the value after every loop of the square, small values will generate the spiral with closely packed loops.

1. From the given statements (Print 12, print "12"), both the statements would print the value 12, The first statement (print 12) can only print the literal value 12 since variable names cannot begin with a number. However, (print a, print "a") statements would make a difference because 'print a' would print the value of able named 'a'.

The way of terminating the recursive function when the value of 'pow' reaches zero, is to use an 'if' condition to evaluate if the value of 'pow' has in fact reached below zero, thereby returning the value 1.

3. The power function from Section 5.3, uses a more efficient means of evaluating a number's exponent by using a more efficient mathematical expression, i.e the function recurses differently depending on whether the given number is even or odd by performing a modulo operation. By this method, the number of multiplications are reduced and thereby, is more efficient due to less memory usage and consumption. On the contrary, the Power function from Section 5.1 simply calls itself with a standard multiplication operator and thereby involves more multiplications and memory usage as a result of which, efficiency is the least. ... Read More

import math

turtle.forward(50)

turtle.right(90)

turtle.forward(50)

turtle.right(90)

turtle.forward(50)

turtle.right(90)

turtle.forward(50)

turtle.right(90+45)

turtle.forward (math.sqrt(2*50*50))

turtle.right(90+45)

turtle.forward(50)

turtle.right(90+45)

turtle.forward (math.sqrt(2*50*50))

turtle.left (45)

turtle.left(45)

turtle.forward (math.sqrt(25*50))

turtle.left(90)

turtle.forward (math.sqrt(25*50))

8. save

#!./bday.py

Answers for Section 2.11, Exercises

1. From the given statements (Print 12, print "12"), both the statements would print the value 12, The first statement (print 12) can only print the literal value 12 since variable names cannot begin with a number. However, (print a, print "a") statements would make a difference because 'print a' would print the value of able named 'a'.

2. The literals from the given piece of code are given below, in each line separately.

1

dog

, went to mow a meadow.

man

and his

,

,

and his

3. The output of the given code is exactly as below :

1 man and his dog , went to mow a meadow. 3 man , 2 man , 1 man and his dog , went to mow a meadow.

4. The Python Interpreter would return the output "8" for the input 4+4/2+2 .

5. print (2)

print (5)

print (6)

6. The correct program to convert from dollars to British pounds is given below :

dollars = 10

conv = 1.75

pounds = dollars / conv

print dollars, "USD is ", pounds,"GBP."

7. The below code for example, uses the a modified convert function to convert US Dollars to Indian Rupees.

def convert (USD, conv, target_c):

result = USD * conv

print USD,"dollars is ",result,target_c

convert (50,...

The best looking spirals however, are those with only a small change in the value after every loop of the square, small values will generate the spiral with closely packed loops.

1. From the given statements (Print 12, print "12"), both the statements would print the value 12, The first statement (print 12) can only print the literal value 12 since variable names cannot begin with a number. However, (print a, print "a") statements would make a difference because 'print a' would print the value of able named 'a'.

The way of terminating the recursive function when the value of 'pow' reaches zero, is to use an 'if' condition to evaluate if the value of 'pow' has in fact reached below zero, thereby returning the value 1.

3. The power function from Section 5.3, uses a more efficient means of evaluating a number's exponent by using a more efficient mathematical expression, i.e the function recurses differently depending on whether the given number is even or odd by performing a modulo operation. By this method, the number of multiplications are reduced and thereby, is more efficient due to less memory usage and consumption. On the contrary, the Power function from Section 5.1 simply calls itself with a standard multiplication operator and thereby involves more multiplications and memory usage as a result of which, efficiency is the least. ... Read More

Cite this document

(“Programming using Python Essay Example | Topics and Well Written Essays - 3250 words”, n.d.)

Retrieved from https://studentshare.net/technology/294001-programming-using-python

Retrieved from https://studentshare.net/technology/294001-programming-using-python

(Programming Using Python Essay Example | Topics and Well Written Essays - 3250 Words)

https://studentshare.net/technology/294001-programming-using-python.

https://studentshare.net/technology/294001-programming-using-python.

“Programming Using Python Essay Example | Topics and Well Written Essays - 3250 Words”, n.d. https://studentshare.net/technology/294001-programming-using-python.

Comments (0)

Click to create a comment

Let us find you another Essay on topic Programming using Python for **FREE!**