0% found this document useful (0 votes)
2 views6 pages

Programming With Python

Uploaded by

snapshop0923
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)
2 views6 pages

Programming With Python

Uploaded by

snapshop0923
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/ 6

PROGRAMMING WITH PYTHON

UNIT-1 ASSIGNMENT-1

1.Write a function is_palindrome(s) that checks if a given string is a


palindrome,Ignore cases and spaces?

Input:

Output:

2.Write a function count_vowels(s) that counts the number of vowels(a,e,i,o,u)


in a string?

Input:
Output:

3.Write a function sort_words(sentence)that takes a sentence,splits it into words,


and returns a list of words sorted Alphabatically?

Input:

Output:
4.Create a function convert_temperature(value,from_unit,to_unit) that converts
temperatures between Celsius,Fahrenheit, and Kelvin.

Input:

Output:

5. Write a function Common_elements(lst1,lst2) that returns a list of elements


common to both input lists.

Input:

Output:
6.Write a recursive function(string_lengths)that calculates the length of a given
string without using built-in functions.

Input:

Output:

7.Write a recursive function binary_to_decimal(binary) that converts a binary


number to its decimal equivalent.

Input:

Output:
8.Write a recursive function count_ways(n) to calculate the numbers of ways to
climb n stairs, where you can take 1 or 2 steps at a time.

Input:

Output:

9.Write a recursive function pascal_triangle(row,col) to compute the value at a


given position in Pascal’s Triangle.

Input:

Output:
10.Write a recursive function matrix_sum(matrix) that calculates the sum of all
elements in a given matrix.

Input:

Output:

You might also like