Informatics2-2021/Lab02

A MathWikiből
A lap korábbi változatát látod, amilyen Imran (vitalap | szerkesztései) 2021. február 17., 05:11-kor történt szerkesztése után volt.
(eltér) ←Régebbi változat | Aktuális változat (eltér) | Újabb változat→ (eltér)

Tartalomjegyzék

Exercises

List first

Write a python program that returns the first element of a list, if there is any, and None is the list is empty. The program should return the first element or a special None value.

List end

Write a program that returns the last c-part of a list!

If the list is shorter than c then return a None value. Otherwise return the list of the last c elements.

Perfect numbers

Write a program which evaluates whether a number is perfect.

Separate

Let L be a list of numbers, write a function that separates its elements into two lists: one for positive and one for non-positive elements. For example

   L = [-1, 2, 5, -2, 3, -4, -5, 2, -2, 0, 5, 5, 6, 3, -3]

Then the result should be two lists.

Elmax

Write a program that finds the largest value in a list and returns the value.

Argmax

Write a program that finds the largest value in a list and returns the index of that element.

The function should be called argmax, should have one parameter: l the list of numbers.

The function should return the index of the largest element. For example [3, 2, 1] should result 0.

Multiply

We have two parameters: a list of numbers l and an additional number k. The output should be a list where every number is k times the corresponding number in l.

Remove Duplicate

Write a python program that remove any duplicate value in a list and return a new list with contains no duplicate.

Intersect

Given two lists. Write a python program that returns true if there is the same value in both lists and returns false otherwise.

Odd Component

Given a list. write a python program which takes all odd values in the list and returns the odd list.

Személyes eszközök