d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Some Help With Python - Paypal Incl
Closed New Topic New Poll
Member
Posts: 5,253
Joined: Apr 4 2008
Gold: 1.70
Warn: 60%
Jun 4 2012 06:40am
so I'm new to python, and have 10 questions that I'd like the answer to, after reviewing and studying the programme.

Possibly as a little bit of an incentive - If someone can answer all questions comprehensively I wouldn't mind doing a $20 paypal transfer or giving you my 250fg ;)

1.Print out the first 50 even numbers. Variations: Odd numbers, increments other than one or two, reverse order.

2.Write a markbook application to read in, store and print out the marks for students. Variations: Fixed sized mark book, multiple marks per student, use either a list or a dictionary.

3.Write a simple calculator, which prompts the user for two numbers and an operator and computes the result. Variations: More than two numbers, repeated calculations (more complex), integer and floating point arithmetic.

4.Read in a string and print out the number of times the letter 'e' appears in the string. Variations: Number of times a whole word appears.

5.A palindrome is a word that reads the same from left to right and right to left. Eg: mom, dad, level. Write a program which prompts for a word and tests if it is a palindrome or not.

6.The Fibonacci sequence is a well known sequence of numbers which was first introduced to Western European mathematics in 1202 by Leonardo of Pisa. The Fibonacci numbers are defined as the sum of the previous two numbers, with the first two numbers being 0 and 1. The first 10 numbers are shown: 0,1,1,2,3,5,8,13,21,34, - Write a function which prompts the user for an input number (of value 3 or more) and outputs that many Fibonacci numbers.

7.Write a program to prompt a user for an integer and then print out the factorial of that number. (Factorial is defined as the multiplication of the integers 1 to n. Eg: 5! = 1 × 2 × 3 × 4 × 5). Variations: Use recursion. (Note this will not appear in the test.)

8.Read in a text file containing a single number per line, and print out the sum on the numbers in the file. Variations: Calculate the average, the smallest and largest numbers.

9.Complex Variation: Allow the file to also have operators and perform a calculation as in question three.

10. Calculate and Print out the first 50 prime numbers. Use a dictionary to add and store phone book entries. Variation: What happens when the user has more than one number?

General questions:

1.What is the difference between a while and until loop.
2.Why would you wish to avoid the infinite loop.
3.What happens if I write a if statement that uses "hello" as its expression?
Member
Posts: 13,630
Joined: Dec 4 2009
Gold: 0.00
Jun 4 2012 10:06am
I can do this, but I am busy for another 6 or so hours. Send me a PM, and I can reply to it later.
Go Back To Programming & Development Topic List
Closed New Topic New Poll