Python and Web Development

Feel free to comment and contact.

Python Programming – John Zelle: Chapter 4 ex. 6

Chapter 4 Exercise 6
Modify the graphical future value program so that the input (principal and apr) also are done in a graphical fashion using Entry objects.

Run =
graph

Python Programming – John Zelle: Chapter 4 ex. 5

Chapter 4 Exercise 5
Write a program that draws 5 dice on the screen depicting a straight (1, 2, 3, 4, 5)

Run =
dice

Python Programming – John Zelle: Chapter 4 ex. 4

Chapter 4 Exercise 4
Write a program that draws a winter scene and some snowmen.

Run =
ch4ex4

Python Programming – John Zelle: Chapter 4 ex. 3

Chapter 4 Exercise 3
Write a program that draws some sort of face.

Run =
ch4ex3

Python Programming – John Zelle: Chapter 4 ex. 2

Chapter 4 Exercise 2
An archery target consists of a central circle of yellow surrounded by concentric rings of red, blue, black and white.
Each ring has the same “width,” which is the same as the radius of the yellow circle.
Write a program that draws such a target. Hint: Objects drawn later will appear on top of objects drawn earlier.

Run =
ch4ex2

Python Programming – John Zelle: Chapter 4 ex. 1

Chapter 4 Exercise 1
Alter the program from the last discussion question in the following ways.
(b) Have each successive click draw an additional square on the screen.(rather than moving the existing one)
(c) Print a message on the window “Click again to quit” after the loop, and wait for a final click before closing the window.

Thanks to Painrinya with some help for this question

Run =
ch4ex1

Python Programming – John Zelle: Chapter 3 ex. 16

#Chapter 3 Exercise 16
A Fibonacci sequence is a sequence of numbers where each successive number is the sum of the previous two.
The classic Fibonacci sequence begins 1, 1, 2, 3, 5, 8, 13,….
Write a program that computes the nth Fibonacci number where the n is a value input by the user

Run =
This program that computes the nth Fibonacci number where the n is a value input by the user
Please input what Fibonacci number you want to be calculated: 6
8

*****************************************

When I first read through the question I read it wrong.
I thought the exercise was to sum the numbers… So here is the result if you want to sum the numbers :)

This program that computes the nth Fibonacci number where the n is a value input by the user
how many numbers would you like to sum? 9
88

Python Programming – John Zelle: Chapter 3 ex. 14

Write a program to find the average of a series of numbers entered by the user.
The program should first prompt the user how many numbers there are.
Note: The average should always be a float, even if the user inputs are all ints

Run =
This program averages a series of numbers entered by the user
How many numbers do you want to average? 5
Enter a number: 3
Enter a number: 4
Enter a number: 4
Enter a number: 6
Enter a number: 5
The total value of your 5 numbers is 22
The average of your 5 numbers is 4.4

Python Programming – John Zelle: Chapter 3 ex. 13

Write a program to sum a series of numbers entered by the user.
The program should first prompt the user how many numbers are to be summed.
It should then input each of the numbers and print a total sum.

Run =
This program adds series of numbers entered by the user
How many numbers do you want to sum? 6
Enter a number: 2
Enter a number: 45
Enter a number: 3
Enter a number: 77
Enter a number: 2
Enter a number: 3
The total value of your 6 numbers is 132

**************************
While the code above works it will fail if a user enters a letter instead of a number.
I edited the code to force valid numbers

Python Programming – John Zelle: Chapter 3 ex. 12

Write a program to find the sum of the cubes of the first (n) natural numbers, where the value of (n) is provided by the user.

Run =
This program to calculates the sum of the cubes of the first natural numbers
How many natural cubes numbers do you want to sum? 7
441