Session 4 - Arrays Flashcards

Arrays (21 cards)

1
Q

String to Array (1min)

Input a List of Numbers separated by space and Print Them

Input: Enter numbers separated by space: 1 2 3 4 5

Output:
[1, 2, 3, 4, 5]

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Array Sum (2mins)

Print the Sum of All Elements

Input: Enter numbers: 1 2 3 4

Output:
Sum = 10

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Minimum/Maximum (2mins)

Find the Maximum and Minimum in a List

Input: Enter numbers: 3 7 1 9

Output:
Max: 9
Min: 1

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Even/Odd Count (2mins)

Count Even and Odd Numbers

Input: Enter numbers: 1 2 3 4 5 6

Output:
Even: 3
Odd: 3

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Reverse without reverse() (2mins)

Reverse a List Without Using reverse()

Input: Enter numbers: 10 20 30

Output:
[30, 20, 10]

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Second Largest (2mins)

Find the Second Largest Number

Input: Enter numbers: 4 1 7 7 3

Output:
Second largest: 4

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

No Dupes (2mins)

Remove Duplicates From a List

Input: Enter numbers: 1 2 2 3 4 4 4 5

Output:
[1, 2, 3, 4, 5]

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Beyond Average/Mean (3mins)

Find All Elements Greater Than Average

Input: Enter numbers: 10 20 30 40

Output:
Average: 25.0
Above average: [30, 40]

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Cyclic Rotation (to the left) (3mins)

Rotate List Left by 1 Position

Input: Enter numbers: 1 2 3 4

Output:
[2, 3, 4, 1]

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

List Merge (2mins)

Merge Two Lists and Sort

Input:
Enter first list: 3 1
Enter second list: 5 2

Output:
[1, 2, 3, 5]

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Join a List of Words into a Sentence (2mins)

Join words from a list into one space-separated string

Input: [“Python”, “is”, “awesome”]

Output:
Python is awesome

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

2x2 Matrix (3mins)

Input a 2×2 Matrix and Print It

Input: Enter 2 rows (space-separated):
1 2
3 4

Output:
[[1, 2], [3, 4]]

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

3x3 matrix sum (3mins)

Sum of All Elements in a 3×3 Matrix

Input: Enter 3 rows:
1 2 3
4 5 6
7 8 9

Output:
Sum = 45

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Transpose (3mins)

Transpose of a 3×3 Matrix

Input:
1 2 3
4 5 6
7 8 9

Output:
[1, 4, 7]
[2, 5, 8]
[3, 6, 9]

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

2x2 Add (3mins)

Add Two 2×2 Matrices

Matrix A:
1 2
3 4

Matrix B:
5 6
7 8

Output:
[6, 8]
[10, 12]

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Diagonal (3mins)

Print Diagonal Elements of a 3×3 Matrix

Input:
1 2 3
4 5 6
7 8 9

Output:
Primary Diagonal: [1, 5, 9]
Secondary Diagonal: [3, 5, 7]

17
Q

Max element (3mins)

Find Max Element in Each Row

Input:
3 1 4
2 5 9
8 7 6

Output:
[4, 9, 8]

18
Q

2x2 Matrix (3mins)

Input a 2×2 Matrix and Print It

Input:
Enter 2 rows (space-separated):
1 2
3 4

Output:
[[1, 2], [3, 4]]

19
Q

3x3 matrix sum (3mins)

Sum of All Elements in a 3×3 Matrix

Input:
Enter 3 rows:
1 2 3
4 5 6
7 8 9

Output:
Sum = 45

20
Q

3x3 matrix 1 row matrix (3mins)

Flatten a 2D Matrix to 1D List

Input:
Enter 3 rows:
1 3 2
4 5 6
7 8 9

Output:
[1, 3, 2, 4, 5, 6, 7, 8, 9]

21
Q

3x3 matrix sum (3mins)

Sum of All Elements in a 3×3 Matrix

Input:
Enter 3 rows:
1 2 3
4 5 6
7 8 9

Output:
Sum = 45