Docsity

CSE111 OOP Oriented Programme, Study notes of Computer Science

Partial preview of the text

Download CSE111 OOP Oriented Programme and more Study notes Computer Science in PDF only on Docsity!

Course Title: Programming Language II

Course Code: CSE 111

Lab Assignment no: 1

String

  1. From a given string, print the string in all uppercase if the number of uppercase

letters is more than lowercase letters. Otherwise, if lowercase is greater or equal

to uppercase letters, print all lowercase. The inputs will contain letters (A-Z, a-z)

only.

Sample Input Sample Output

HOusE HOUSE

ApplE apple

BaNaNa banana

  1. Given a string, print whether it is a number, word or mixed with digit and letters.

If all the characters are numeric values, print NUMBER. If they are all letters, print

WORD. If it is mixed, print MIXED.

Sample Input Sample Output

213213 NUMBER

jhg231j213 MIXED

Hello WORD

  1. In a given string, there will be two uppercase letters in between some lowercase

letters. Print the substring from the first uppercase letter to the last uppercase letter

excluding them. If there are no letters in between them, print the word BLANK. It

is guaranteed that there will be only two uppercase letters in the string.

Sample Input Sample Output

baNgladEsh glad

coDIng BLANK

Sample Input

ohMyBR@CU

ohmybracu

OhMyBR@CU

Sample Output

Digit missing

Uppercase character missing, Digit missing, Special character missing

OK

  1. Again, you have lost your USIS password!! You went to the registrar office and

requested for a new password. This time, you need to follow some rules to set your

password. Otherwise, they won't change it. The rules are

At least one lowercase letter

At least one uppercase letter

At least one digit (0-9)

At least one special character (_ , $ , #, @)

Your task is to find whether a given password follows all those rules. If it breaks

any rule, you have to print Lowercase Missing, Uppercase Missing, Digit Missing

or Special Missing respective to the missing case. For more than one rule break,

print all the rules that were broken (order doesn't matter). If the password is ok,

print OK.

Sample Input

STOP

Sample Output

10 - 2 times

20 - 2 times

30 - 1 times

50 - 1 times

90 - 1 times

Sample Input

Sample Output

[10, 11, 12]

List

1. Write a python program which prints the frequency of the numbers that were given

as input by the user. Stop taking input when you find the string “STOP”. Do not

print the frequency of numbers that were not given as input.

  1. Write a python program that calculates the sum of N given lists and prints the highest

sum and its respective list. Input starts with N and followed by N lists.

Sample Input 1

Sample Input 2

Sample Input 3

Sample Output 1

Sample Output 2

Sample Output 3

  1. BRACU has n students who are regular competitive programmers. According

to the ACM ICPC rules, each person can participate in the regional championship

at most 5 times.

The head of the BRACU ACM Chapter is recently gathering teams to participate

in this championship. Each team must consist of exactly three people, at that, any

person cannot be a member of two or more teams. What maximum number of teams

can the head make if he wants each team to participate in the world championship

with the same members at least k times?

The first line of input contains two integers, n and k. The next line contains n

integers: y 1

, y 2

, ..., y n

( 0 ≤ yi ≤ 5 ), where y i

shows the number of times the i - th person

participated in the ACM ICPC Regional.

Write a python program that prints how many teams can be formed according to

the above problem statement.

Sample Input

a: 100, b: 100, c: 200, d: 300

a: 300, b: 200, d: 400, e: 200

Sample Output

{'a': 400, 'b': 300, 'c': 200,'d': 700, 'e': 200}

Values: (200, 300, 400, 700)

Sample Input

STOP

Sample Output

10 - 2 times

20 - 2 times

30 - 1 times

50 - 1 times

90 - 1 times

Dictionary & Tuple

  1. Write a Python program to combine two dictionaries into one by adding values for

common keys. Input contains two comma separated dictionaries. Print the new

dictionary and create a tuple which contains unique values in sorted order.

2. Write a python program which prints the frequency of the numbers that were

given as input by the user. Stop taking input when you find the string “STOP”. Do

not print the frequency of numbers that were not given as input. Use a dictionary

to solve the problem

Sample Input

Hello, World!

Sample Output

  1. On some basic cell phones, text messages can be sent using the numeric keypad.

Because each key has multiple letters associated with it, multiple key presses are

needed for most letters. Pressing the number once generates the first character listed

for that key. Pressing the number 2, 3, 4 or 5 times generates the second, third, fourth

or fifth character.

Key Symbols

1 .,?!:

2 ABC

3 DEF

4 GHI

5 JKL

6 MNO

7 PQRS

8 TUV

9 WXYZ

0 Space

Write a program that displays the key presses needed for a message entered by the user.

Construct a dictionary that maps from each letter or symbol to the key presses needed to

generate it. Then use the dictionary to create and display the presses needed for the user’s

message.