KEMBAR78
Python Lab | PDF
0% found this document useful (0 votes)
6 views2 pages

Python Lab

The document outlines five programming tasks for a Python lab. These tasks include creating functions to draw a triangle of hashes, find the greatest of three numbers, calculate a specific series sum, compute the factorial of a number, and check if a word is a palindrome. Each task specifies the expected functionality and provides examples for clarity.

Uploaded by

modyesam25
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)
6 views2 pages

Python Lab

The document outlines five programming tasks for a Python lab. These tasks include creating functions to draw a triangle of hashes, find the greatest of three numbers, calculate a specific series sum, compute the factorial of a number, and check if a word is a palindrome. Each task specifies the expected functionality and provides examples for clarity.

Uploaded by

modyesam25
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/ 2

Python Lab (3)

1) Please write a function named triangle, which draws a triangle of


hashes, and takes one argument. The triangle should be as tall and
as wide as the value of the argument.
Some examples:
triangle(6)
triangle(3)

#
##
###
####
#####
######

#
##
###

2) Please write a function named greatest_number, which takes three


arguments. The function returns the greatest in value of the three.
[without using max function, and solve it in two ways]
print(greatest_number(3, 4, 1)) # 4
print(greatest_number(99, -4, 7)) # 99
print(greatest_number(0, 0, 0)) # 0
3) Write a function sum_series(n) that calculates the sum of the
series:
1 - 2 + 3 - 4 + 5 - ... up to n

4) Write a Python function to calculate the factorial of a number (a


non-negative integer). The function accepts the number as an
argument.

5) Implement a function that checks if a given word is a palindrome


(reads the same forwards and backwards)

You might also like