0% found this document useful (0 votes)
54 views3 pages

Laboratoriya 3

The document provides examples of Python programming exercises involving dictionaries, strings, tuples, matrices, and other data structures. The exercises include replacing dictionary values with averages, counting unique characters in a string, determining if two words are anagrams, calculating Scrabble scores using a letter-point dictionary, finding repeated items in a tuple, accessing specific tuple elements, checking if all items in a tuple are the same, combining expressions to make a 10-character string, writing each letter of a phrase as an expression repeating up to the letter number, counting words in a sentence, calculating the sum of diagonal matrix elements, adding a number to a matrix, transposing a matrix, and adding two matrices.

Uploaded by

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

Laboratoriya 3

The document provides examples of Python programming exercises involving dictionaries, strings, tuples, matrices, and other data structures. The exercises include replacing dictionary values with averages, counting unique characters in a string, determining if two words are anagrams, calculating Scrabble scores using a letter-point dictionary, finding repeated items in a tuple, accessing specific tuple elements, checking if all items in a tuple are the same, combining expressions to make a 10-character string, writing each letter of a phrase as an expression repeating up to the letter number, counting words in a sentence, calculating the sum of diagonal matrix elements, adding a number to a matrix, transposing a matrix, and adding two matrices.

Uploaded by

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

1.Write a Python program to replace dictionary values with their average.

2. Create a program that determines and displays the number of unique characters in a string
entered by the user. For example, Hello, World! has 10 unique characters while zzz has only
one unique character. Use a dictionary or set to solve this problem.
3. Two words are anagrams if they contain all of the same letters, but in a different
order. For example, “evil” and “live” are anagrams because each contains one e, one i, one l,
and one v. Create a program that reads two strings from the user, determines whether or not
they are anagrams, and reports the result.
4. In the game of Scrabble™, each letter has points associated with it. The total score of a
word is the sum of the scores of its letters. More common letters are worth fewer points while
less common letters are worth more points. The points associated with each letter are shown
below:

Write a program that computes and displays the Scrabble™ score for a word.
Create a dictionary that maps from letters to point values. Then use the dictionary to compute
the score.
P.S. A Scrabble™ board includes some squares that multiply the value of a letter
or the value of an entire word. We will ignore these squares in this exercise.
5. Write a Python program to find the repeated items of a tuple.
6. Write a Python program to get the 4th element and 4th element from last of a tuple.
7. Check if all items in the following tuple are the same
8. Write an algorithm that tries to make a 10-character expression by combining two
expressions. If the number of characters in two expressions is not enough to make a 10-
character expression, add the * sign to the end of the short expression to complete the
required number of characters.
Input:
first word: COVİD
second word: 19
Output: COVİD19 *
9. Write each letter of the phrase entered from the keyboard as a new expression, repeating it
up to the sequence number of the letter.
Input: Foundation
Output: Foouuunnnndddddaaaaaatttttttiiiiiiiiooooooooonnnnnnnnnn
10. Write a program that finds the number of words in an inserted sentence.
Input: Hello world!
Output: 2
11. Given array calculate the sum of diagonal elements.

Ex: [[2,7,5],[3,4,6],[9,6,1]] => sum of 2+ 4 + 1 =7

12. Write a program to add a number to a matrix-

13. Write a program to transpose a matrix-

Transpose of a matrix is the interchanging of rows and columns. It is denoted as X'. The
element at ith row and jth column in X will be placed at jth row and ith column in X'. So
if X is a 3x2 matrix, X' will be a 2x3 matrix.

Input:

240

517

Output:

25

41

07

14. Write a program to add two matrices

Input:

X= [[3,2,1],
[5 ,6,7],
[7 ,8,9]]

Y = [[9,8,7],
[3,5,4],
[0,2,1]]

Output :
result= [[12,10,8],
[8,11,11],
[7,10,10]]

You might also like