0% found this document useful (0 votes)
142 views

Programming Exercises: Itworks L91709029N WWW - It-Works - Io Contact@It-Works - Io +355 4 562 9090

The document contains 7 programming exercises: 1) Write a function to check if a number is even 2) Write a function to check if a number is a palindrome 3) Write a function to check if a number is a power of 2 4) Write a function to convert a string to uppercase if it contains 2+ uppercase in first 4 characters 5) Iterate a list, display numbers divisible by 5 until a number >150 is found 6) Write a function to group words in a list by their length into a dictionary 7) Create Person and Student classes with get_fullname functions to return full names with '-st.' for students

Uploaded by

Nikolin Cami
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)
142 views

Programming Exercises: Itworks L91709029N WWW - It-Works - Io Contact@It-Works - Io +355 4 562 9090

The document contains 7 programming exercises: 1) Write a function to check if a number is even 2) Write a function to check if a number is a palindrome 3) Write a function to check if a number is a power of 2 4) Write a function to convert a string to uppercase if it contains 2+ uppercase in first 4 characters 5) Iterate a list, display numbers divisible by 5 until a number >150 is found 6) Write a function to group words in a list by their length into a dictionary 7) Create Person and Student classes with get_fullname functions to return full names with '-st.' for students

Uploaded by

Nikolin Cami
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/ 1

ITWorks

L91709029N
www.it-works.io
contact@it-works.io
+355 4 562 9090

Programming Exercises
1 Write a function to check if a number is even.
(input 2: output True, input 3: output False)

2 Write a function to check if a number is palindrome.


(121 is palindrome, 321 is not)

3 Write a function to check if a number is power of 2.


(1, 2, 4 power of 2, 3 is not)

4 Write a function to convert a given string to all uppercase if it contains at least 2


uppercase characters in the first 4 characters.

5 Given a list iterate it and display numbers which are divisible by 5 and if you
find number greater than 150 stop the loop iteration
list1 = [12, 15, 32, 42, 55, 75, 122, 132, 150, 180, 200]

6 Write a function that takes a list of words and groups the words by their length
using a dictionary
Input: [‘Lorem, ‘ele’, ‘sit’, ‘incididunt’, ‘a’, ‘su’, ‘dom’, ‘ouch’, ‘ipsum’’]
Output:
{
1: [‘a’],
2: [‘su’],
3: [‘ele’, ‘sit’, ‘dom’]
5: [‘Lorem’, ‘ipsum’]
10: [‘incididunt’]
}

7 Create a class Person with first_name and last_name as constructor


parameters. The class should have a function get_fullname which returns the
person’s full name (first_name + last_name). Create another class Student,
inheriting from Person. Student’s get_fullname function should return students
full name followed by ‘-st.’

You might also like