Midterm(repeat)

A MathWikiből
(Változatok közti eltérés)
(Új oldal, tartalma: „=Programming Problems:= ==Problem 1 (2 points)== Write a function which input is a list containing strings and the output is a dictionary, where the keys are the eleme…”)
 
(Programming Problems:)
 
1. sor: 1. sor:
 
=Programming Problems:=
 
=Programming Problems:=
  
==Problem 1 (2 points)==
+
==Problem 1 ==
 
Write a function which input is a list containing strings and the output is a dictionary, where the keys are the elements of the
 
Write a function which input is a list containing strings and the output is a dictionary, where the keys are the elements of the
 
list and the values are the index of the corresponding elements.
 
list and the values are the index of the corresponding elements.
  
==Problem 2 (3 points)==
+
==Problem 2 ==
 
Write a function which calculates the least common multiple of two positive natural numbers. (Hint: Use while cycle.)
 
Write a function which calculates the least common multiple of two positive natural numbers. (Hint: Use while cycle.)
  
==Problem 3 (4 points)==
+
==Problem 3 ==
 
D is a dictionary, where the keys are letters from the english alphabet, and the values are numbers in string format.
 
D is a dictionary, where the keys are letters from the english alphabet, and the values are numbers in string format.
 
Write a function which input is a dictionary like that and the output is a dictionary, which has two keys: "vowel", "consonant"  
 
Write a function which input is a dictionary like that and the output is a dictionary, which has two keys: "vowel", "consonant"  
18. sor: 18. sor:
 
(Hint: We consider a, e, i, o, u as vowels.)
 
(Hint: We consider a, e, i, o, u as vowels.)
  
==Problem 4 (5 points)==
+
==Problem 4 ==
 
Write a Python program to create a list reflecting the run-length encoding from a given list of integers or
 
Write a Python program to create a list reflecting the run-length encoding from a given list of integers or
 
a given list of characters.
 
a given list of characters.

A lap jelenlegi, 2021. június 15., 09:40-kori változata

Tartalomjegyzék

Programming Problems:

Problem 1

Write a function which input is a list containing strings and the output is a dictionary, where the keys are the elements of the list and the values are the index of the corresponding elements.

Problem 2

Write a function which calculates the least common multiple of two positive natural numbers. (Hint: Use while cycle.)

Problem 3

D is a dictionary, where the keys are letters from the english alphabet, and the values are numbers in string format. Write a function which input is a dictionary like that and the output is a dictionary, which has two keys: "vowel", "consonant" and the values are the sum of the values of the corresponding letters in string format. For example:

     If D = { 'a' : '5', 'b' : '2', 'c' : '3', 'e' : '5' }, 
     then it returns:
     { "vowel" : '10', "consonant" : '5' }

(Hint: We consider a, e, i, o, u as vowels.)

Problem 4

Write a Python program to create a list reflecting the run-length encoding from a given list of integers or a given list of characters.

Run-length encoding (RLE) is a form of lossless data compression in which runs of data (sequences in which the same data value occurs in many consecutive data elements) are stored as a single data value and count, rather than as the original run. For example:

'aaabaaa' --> [[3, 'a'], [1, 'b'], [3, 'a']]
'babaaaa' --> [[1, 'b'], [1, 'a'], [1, 'b'], [4, 'a']]
'bbbbbbbbbb' --> [ [10, 'b'] ]
Személyes eszközök