Python programs, Python Programming

Python Programs

You must submit the source code and samples of output for each program.Please do not provide python file (eg. Copy all source code to one word file.

1) Write a program that simulates the Math method 'sqrt'. The program will read real Values as input and calculate the value as square root of the input value (Use math library). This will then output to screen as following two examples:

Input of 2, should return 1.

Input of 4, should return 2.  

2) Write a python code comparing while andfor loops (ie. Times tableeg. 2x1=2, 2x2=4,...).

3) Write a program to input a year and determine whether or not it is a leap year. A year is a leap year if it is divisible by 4 but not by 100 unless it is also divisible by 400.

4) Write a programme that calculates: How much an amount deposited in a bank account at r% annual interest has grown to after one, two and three years. The general formula for computing the amount including after n years is: Kn= k0 *(1+r/100)n

5) Write a program that reads a line of text from the keyboard, and prints it back after replacing each occurrence of any four-letter word in the text with the word "x***", where x is the first character in the four-letter word.

Example: Input the string "This apple tree is the best"

                 Is replace to "T*** apple t*** is the b***"

6) Write a program that reads a sequence of integers from a fileand prints a frequency report showing how many times the integers 0, l, ..., 9 occur in the sequence.

7) Write a program that uses paired array. The first list (array) represents all the student grades (F2, F1, P1, P2, C, D, HD), while the second list (array) holds the corresponding cutoff percentagemark required (0, 45, 50, 60, 70, 80, 90). The program should prompt and read a percentage value as input. The task is to match the grade with the cutoff percentage mark. The grade is output to the screen.

8) Write a program that reads a list of twenty integers from a file and stores them in an array. The program should print the position of the smallest number in the array. If the position of the smallest number is other than 0, the program should swap the number in position 0 with the smallest value. After swapping, the smallest number is now in position 0 and the number that was previously in position 0 is now where the smallest number was. Finally the program should print the values in the array.

9) Write a class Player that stores the name,type of sport, position and score. Include the Constructor, Accessor and Mutator methods.

10) Include in the question 8 the four methods, the methods to reset score, increase and decrease the score and to print the current score.

Posted Date: 3/2/2013 12:55:39 AM | Location : United States

Related Discussions:- Python programs, Assignment Help, Ask Question on Python programs, Get Answer, Expert's Help, Python programs Discussions

Write discussion on Python programs
Your posts are moderated
Related Questions
Data array A has data series from 1,000,000 to 1 with step size 1, which is in perfect decreasing order. Data array B has data series from 1 to 1,000,000, which is in random order.

We encourage you to adopt an interactive style of debugging and programming. Use the Python shell a lot. Write short pieces of code and check them.  It is much  simpler to test the

Expressions and assignment We can think of most computer programs as performing some sort of transformation on data.  Our code may get as input the exam scores of everyone in

Normalize a vector Let's imagine we want  to normalize a vector  of three  variables;  that  is to compute a new  vector  of three values,  such that its size  is 1. Here is o

I have a C++ code (10-15 line) which i need to re-write in python with the help of ctypes library. Is it possible i can get some help with it? Thanks & regards Tanmoy

List Comprehensions   Python has a very nice built-in  facility for doing  many  iterative methods, known as list comprehensions. The basic template is       [

Tuples  and strings Python has two different more list-like data  types  that are very important to understand.A tuple  is a structure that  is like a list, but  is not  mutab

I need server, client and trusted side communicating and charging a service with that protocol (or needham shroeder)

1 Low Level Exploits 1.1 Savegames Jimmy is becoming increasingly frustrated at the computer game hes playing. He has a save right before the levels boss but he needs either more

Assume you have a truck which has to travel across a desert from the base camp at position 0 (left) to the target camp at position 4 (right). The intermediate positions 1,2, and 3