Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views1 page

Assignment

The document outlines three Python exercises: the first requires printing the sum of the current and previous numbers in a range of 10 using f-strings; the second involves creating a Stopwatch class with start and stop methods; and the third is a function to check if a word is a palindrome, returning an error for non-string inputs.

Uploaded by

farooq112ab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Assignment

The document outlines three Python exercises: the first requires printing the sum of the current and previous numbers in a range of 10 using f-strings; the second involves creating a Stopwatch class with start and stop methods; and the third is a function to check if a word is a palindrome, returning an error for non-string inputs.

Uploaded by

farooq112ab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python Assignment

Exercise 1
Print the Sum of a Current Number and a Previous number.

Your expected output should be:

Printing the current and previous number sum in a range(10)

Current Number 0, Previous Number 0, Sum: 0

Current Number 1, Previous Number 0, Sum: 1

Current Number 2, Previous Number 1, Sum: 3

Current Number 3, Previous Number 2, Sum: 5

Current Number 4, Previous Number 3, Sum: 7

Current Number 5, Previous Number 4, Sum: 9

Current Number 6, Previous Number 5, Sum: 11, etc


And accomplish this using f-string.

Exercise 2

Create a class called Create Stopwatch. Each stopwatch object

should have two methods: one to start(), which will start the

stopwatch, and a Second to stop(), which will stop the stopwatch

and print the seconds that have passed

Exercise 3

Create a function called is Palindrome, which will take any word as

a parameter and tell whether this word is a palindrome or not

and if the input parameter is not a string, then it will return saying

invalid type. (A palindrome is a word that is the

same as its reverse.)

You might also like