Python programs, Python Programming

Assignment Help:

Python Programs

You must submit the source code and samples of output for each program.Please do not provide python file (eg. Filename.py). 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.


Related Discussions:- Python programs

If statements, how do you make an if and else statment work in pytho?

how do you make an if and else statment work in pytho?

Example of Procedures as First-class objects, Procedures in Firrst-class ob...

Procedures in Firrst-class objects In Python, unlike  many  other  languages, methods are behave in much  the same way as num­ bers:  they  can be stored as values  of variabl

Conditionals- booleans, Booleans   Before we talk about  conditional...

Booleans   Before we talk about  conditionals, we require  to clarify the Boolean  data  type.  It has two values False and True. Typical statement that have Boolean values

Expert, how can i become an expert & solution provider in the CS/IT field?

how can i become an expert & solution provider in the CS/IT field?

Print vs return, Print vs Return Here are two different method declara...

Print vs Return Here are two different method declarations: def f1(x): print x + 1 def f2(x): return x + 1 What happens when  we call them? >>> f1(3) 4 >>

Example of python code, Worked example 1   Let's examine what  happens...

Worked example 1   Let's examine what  happens when  we compute the following Python code:   def p(x, y): z = x*x - y return z + 1/z   >>> p(1.0, 2.0) -2.0

Tower of Hanoi, Tower of Hanoi game that you can let a player to move discs...

Tower of Hanoi game that you can let a player to move discs between the towers using a mouse. Moreover, you are required to do the followings: •Graphically represent any state in t

Variables, Variables We cannot  go very far without variables. A variabl...

Variables We cannot  go very far without variables. A variable is a value related to a name that we can bind  to have a particular value  and  then  later use in an expression.

Python program, Write a program that asks the user to enter a number of sec...

Write a program that asks the user to enter a number of seconds. The responses of the program will vary depending on the length of seconds: • If the number of seconds is under 60

Van der waals equation of state, how to make a python programme for van der...

how to make a python programme for van der waals equation of state with surface discontinouty

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd