Unit - IV
Unit - IV
Dhiyanesh
Associate Professors / CSE – E Tech
SRM Institute of Science and Technology,
Vadapalani Campus, Chennai
CLR-2: Utilize the appropriate operators and control statements to solve engineering
problems
CLR-4: Create custom designed functions to perform repetitive tasks in any application
CLR-6: Create applications using suitable python library functions for solving data
science problems.
21CSC203P - Advanced Programming Practice - SRMIST - VDP 2
COURSE OUTCOME
CLO-1:To solve problems through computer programming. Express the basic data types and
variables in C
CLO-2:To use appropriate data types in simple data processing applications. To create programs
using the concept of arrays.
CLO-3:To create string processing applications with single and multi-dimensional arrays.
CLO-4:To create user defined functions with required operations. To implement pointers in
applications with dynamic memory requirements.
CLO-5:To create programs using the python data types, loops, control statements for problem
solving
CLO-6:To implement the suitable python library based solutions for solving statistical problems
in data science
21CSC203P - Advanced Programming Practice - SRMIST - VDP 3
CONTINUOUS LEARNING ASSESSMENT (CLA)
• https://www.tutorialspoint.com/cprogramming/index.htm
• https://www.geeksforgeeks.org/c-programming-language/
Floating Points, Boolean types - Working with String functions - Working with Input, Output
functions - Python-Single and Multi line Comments/ Error Handling - Conditional & Looping
Statements : If, for, while statements - Working with List structures - Working with Tuples
data structures - Working with Sets - Working with Dictionaries - Introduction to Python
he
o
hello javatpointhello javatpoint
hello javatpoint how are you
21CSC203P - Advanced Programming Practice - SRMIST - VDP 28
LIST
• Lists in Python are like arrays in C, but lists can contain data of different types.
• The things put away in the rundown are isolated with a comma (,) and encased inside square
sections [].
• To gain access to the list's data, we can use slice [:] operators.
• Like how they worked with strings, the list is handled by the concatenation operator (+) and
the repetition operator (*).
• Look at the following example.
• Output:
• Enter a value: 45
• You entered: 45
Output:
• val = input("Enter an integer: ") Enter an integer: 12
Square of the value: 144
• val = int(val) # casting into string
• sqr = (val*val) # getting square
• print("Square of the value:",sqr)
Output:
enter the number: 10
The Given number is an even number
Output:
The list of squares is [16, 4, 36, 49, 9, 25, 64, 100, 36, 1, 81, 4]
• # example Output:
• a = [ 1, 2, "Ram", 3.50, "Rahul", 5, 6]
True
• b = [ 1, 2, "Ram", 3.50, "Rahul", 5, 6]
• a == b
• print(list[2]) 1
• print(list[3]) 2
3
• print(list[0:6]) # Slicing the elements 4
• print(list[:]) [1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6, 7]
• print(list[2:5]) [3, 4, 5]
• print(list[1:6:2]) [2, 4, 6]
• # repetition operator * [12, 14, 16, 18, 20, 12, 14, 16, 18, 20]
• l = list1 * 2
• print(l)
• l = list1 + list2
• print(l)
6
• list1 = [12, 16, 18, 20, 39, 40] 40
• print(len(list1)) 12
• print(max(list1))
• print(min(list1))
• Example
• ("Suzuki", "Audi", "BMW"," Skoda ") is a tuple.
Output:
• print(Days)
Output:
• print("looping through the set elements ... ")
• for i in Days: {'Wednesday', 'Sunday', 'Monday', 'Tuesday', 'Thursday', 'Friday', 'Saturday'}
looping through the set elements ...
• print(i) Wednesday
Sunday
Monday
Tuesday
Thursday
Friday
Saturday
Output:
Output:
Output:
{'Monday', 'Tuesday'}
{'castle'}
Output:
{'Thursday', 'Wednesday'}
• Output:
• {3, 4, 5, 6, 8, 9, 10}
• Output
• <class 'dict'>
• printing Employee data ....
• {'Name': 'Johnny', 'Age': 32, 'salary': 26000, 'Company': TCS}