Docsity

robotics programming, Exercises of Robotics

Toggle sidebar
bg1
Department of Electrical Engineering
Bahria University
Assignment 1
Program: RIS
Semester: 5
Course: Robotic Systems & Programming
Marks: 50
Instructor Name: Dr. Shaheryar Najam
Question 1:
You are given a list of student records in the format:
students = [["Ali", 85], ["Sara", 92], ["Ahmed", 76], ["Noor", 92]]
Write a function that:
Finds the highest marks.
Prints the names of students who got those marks.
Question 2:
Write a function that takes a list of words and groups together all the anagrams.
Example: ["eat", "tea", "tan", "ate", "nat", "bat"] → [["eat", "tea",
"ate"], ["tan", "nat"], ["bat"]].
Question 3:
Write a function that finds the length of the longest increasing subsequence in a list (not
necessarily consecutive).
oExample: [10, 22, 9, 33, 21, 50] → 4 (subsequence [10, 22, 33,
50]).
Question 4:
Write a program that transposes a 2D list (matrix) using loops.
Example:
[[1, 2, 3],
[4, 5, 6]]
[[1, 4],
[2, 5],
[3, 6]]
Question 5:
Write a function that sorts a list of integers such that:
oAll even numbers appear first in ascending order.
pf2

Partial preview of the text

Download robotics programming and more Exercises Robotics in PDF only on Docsity!

Department of Electrical Engineering Bahria University Assignment 1 Program: RIS Semester: 5 Course: Robotic Systems & Programming Marks: 50 Instructor Name: Dr. Shaheryar Najam Question 1: You are given a list of student records in the format: students = [["Ali", 85], ["Sara", 92], ["Ahmed", 76], ["Noor", 92]] Write a function that:  Finds the highest marks.  Prints the names of students who got those marks. Question 2: Write a function that takes a list of words and groups together all the anagrams.  Example: ["eat", "tea", "tan", "ate", "nat", "bat"] → [["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]. Question 3: Write a function that finds the length of the longest increasing subsequence in a list (not necessarily consecutive). o Example: [10, 22, 9, 33, 21, 50] → 4 (subsequence [10, 22, 33, 50]). Question 4: Write a program that transposes a 2D list (matrix) using loops. Example: [[1, 2, 3], [4, 5, 6]] [[1, 4], [2, 5], [3, 6]] Question 5: Write a function that sorts a list of integers such that: o All even numbers appear first in ascending order.

Department of Electrical Engineering Bahria University o All odd numbers appear next in descending order. o Example: [5, 2, 8, 7, 1, 6] → [2, 6, 8, 7, 5, 1]. Question 6: Write a function that checks if two words differ by exactly one letter.  Example: ("cat", "bat") → True, ("cat", "dog") → False. Question 7: Write a function that rotates a square matrix 90 degrees clockwise. Example: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [[7, 4, 1], [8, 5, 2], [9, 6, 3]] Question 8: Write a program that takes a list of integers and prints a simple histogram using *. Example: [3, 5, 2] →

** Question 9: Write a function that checks if one list is a sublist of another.  Example: ([1, 2, 3], [2, 3]) → True, ([1, 2, 3], [3, 2]) → False. Question 10: Write a function that checks if a given n x n matrix is a magic square (sum of each row, column, and diagonal is the same).