Gen-AI Developer Classroom notes 21/Sep/2025

lists contd..

  • Matrices using list
  • in python we have a library (not part of standard installation of python) called as Numpy which is widely used for matrix operations.

dictionary

  • Refer Here for samples
  • dictionary is mutable
  • syntax for empty dictionary
x = dict()
x = {}
  • with values
marks = {
    'maths': 100,
    'science': 89,
    'english': 60
}

string

Problem – 1

  • Lets write a program which maintains the total amount spend on different categories
    • food
    • entertainment
    • utilities
    • shopping
  • Ask two questions amount and category continously
    • if the category doesnot exist add it
    • if the category exists add current expenditure to the alredy present
  • Create a dicitonary
    • key = category
    • value = total amount spent

Problem – 2

  • User enters a sentence
  • you are supposed to calculate word frequency
The car ran over speedbreaker and car got broke down

word frequency
the     1
car     2
ran     1
over    1
speedbreaker 1
and     1
got     1
broke   1
down    1
  • Example
The quick brown fox jumps over the lazy dog and the dog barked back at the fox
Here’s the word frequency (case-insensitive):
the → 4
fox → 2
dog → 2
quick → 1
brown → 1
jumps → 1
over → 1
lazy → 1
and → 1
barked → 1
back → 1
at → 1

By continuous learner

enthusiastic technology learner

Leave a Reply

Discover more from Direct AI Powered By Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading