Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Thursday, 27 March 2025

Work Diary - 2025

Learnt:

Date

Link

28.01.2025

https://ametodl.blogspot.com/p/experience-with-deepseek-r1.html

02.02.2025

https://dockerhandson25.blogspot.com/

03.02.2025

https://dockerhandson25.blogspot.com/2025/02/dockerize-react-project-handson.html

03.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/1-angular-19-tutorials.html

04.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/4-session-3-directives-pipes-services-2.html

04.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/5-session-4-routing-navigation-2-hours.html

04.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/62-template-form-validation.html

04.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/63-reactive-form-validation.html

04.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/64-side-nav-bar-demo.html

04.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/6-session-5-forms-validation-2-hours.html

04.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/7-crud-in-angular-19.html

04.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/7-crud-made-simple.html

04.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/80-sqlite-installation.html

04.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/81-sqlite-tutorial-basics.html

04.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/82-sqlite-crud-advanced-topis.html

07.02.2025

https://dockerhandson25.blogspot.com/2025/02/ai-agent-basics-hands-on.html

07.02.2025

https://gamma.app/docs/Pydantic-AI-Agents-Making-AI-Work-for-You-sbulct84mtrt9db

12.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/10-input-decorator-concepts.html

12.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/11-output.html

12.03.2025

https://ang-19-tutorials.blogspot.com/2025/03/9-signals.html

13.01.2025

https://learn-gemini2.blogspot.com/2025/01/

13.03.2025

https://type-script-tutorials.blogspot.com/

14.03.2025

https://gcp-handson.blogspot.com/2025/03/run-ollama-in-co-lab.html

15.02.2025

https://ametodl.blogspot.com/2022/11/angular-1-installation.html

15.02.2025

https://ametodl.blogspot.com/2022/11/angular-2-string-interpolation.html

15.02.2025

https://ametodl.blogspot.com/2022/11/angular-3-directives.html

15.02.2025

https://ametodl.blogspot.com/2022/11/angular-4-routing.html

16.02.2025

https://ametodl.blogspot.com/2022/11/angular-5-with-json.html

16.02.2025

https://ametodl.blogspot.com/2022/11/angular-6-ngclass.html

16.02.2025

https://ametodl.blogspot.com/2022/11/angular-7-service.html

16.02.2025

https://ametodl.blogspot.com/2022/12/angular-8-forms.html

16.02.2025

https://ametodl.blogspot.com/2022/12/ionic-angular-1-demo.html

16.02.2025

https://ametodl.blogspot.com/2024/12/academic-paper-pipeline.html

18.02.2025

https://learn-gemini2.blogspot.com/2025/02/temp-angular-for-immss.html

19.02.2025

https://angular.dev/tutorials/learn-angular/1-components-in-angular

19.02.2025

https://candwebapp2024.blogspot.com/2025/01/3-sass.html

20.02.2025

https://angular-material.dev/articles/angular-material-theming-system-complete-guide

20.02.2025

https://learn-gemini2.blogspot.com/2025/02/angular-material-theming-color.html

20.02.2025

https://material.angular.io/guide/getting-started

20.02.2025

https://material.angular.io/guide/theming

21.02.2025

https://learn-gemini2.blogspot.com/2025/02/angular-material-typography.html

21.03.2025

https://gcp-handson.blogspot.com/2025/03/1-k8s-intro-lab.html

22.02.2025

https://learn-gemini2.blogspot.com/2025/02/deep-seek-in-colab.html

23.01.2025

https://hugfacehandson.blogspot.com/

23.01.2025

https://ollamabasic.blogspot.com/2025/01/local-llm-for-immss-ai.html

23.02.2025

https://gcp-handson.blogspot.com/2025/02/gcp1.html

24.03.2025

https://qc-python-basics.blogspot.com/2025/03/1-popular-python-libraries-for-quantum.html

25.03.2025

https://gcp-handson.blogspot.com/2025/03/temp-for-discussion.html

26.03.2025

https://civil-engg-ai.blogspot.com/2025/03/pyautocad-intro.html

27.02.2025

https://gcp-handson.blogspot.com/2025/02/caai-33-git-docker-push-for-frontend.html

27.02.2025

https://github.com/au60rmc/immibizsoft-frontend

27.03.2025

https://auto-fill-form.blogspot.com/2025/03/2-devops-beginners-hands-on.html

27.03.3025

https://dev-ops-hands-on.blogspot.com/2025/03/1-devops-basics-hands-on.html

26.03.2025

https://auto-fill-form.blogspot.com/2025/03/1-basic-form-filling-using-selenium.html

04.05.2025

https://learn-gemini2.blogspot.com/2025/05/builderio-tutorials.html

05.05.2025

https://tnsche-sirf.blogspot.com/2025/05/1-nirf-overall-discrepancies.html

12.05.2025

https://tnsche-sirf.blogspot.com/2025_05_12_archive.html

14.05.2025

https://tnsche-sirf.blogspot.com/2025/05/mapping-job-roles-and-aligning.html

16.05.2025

https://tnsche-sirf.blogspot.com/2025/05/10-prominent-itites-industries-in.html

17.05.2025

https://tnsche-sirf.blogspot.com/2025/05/skills-in-demand-2025-from-job-web-sites.html                                                                             

18.05.2025      

https://out-come-based-education.blogspot.com/2025/05/obe-training-modules.html

 May 2025 

https://tn-phd-ecosystem.blogspot.com/

01.08.2025 

https://tnsche-sirf.blogspot.com/

03. 07.2025  

https://july2025-works.blogspot.com/

May 30, 2025 

https://out-come-based-education.blogspot.com/

June 2, 2025 

https://p-e-p-2025.blogspot.com/

2.8.2025

https://ai-drug-discovery.blogspot.com/

23.08.2025  

https://py4civil.blogspot.com/



github for Python            https://github.com/aurmc2018/hello-world.git

github for TANSCHE     https://github.com/TANSCHEC/sirf.git

githubfor CAAI              https://github.com/immbizsoft/caai-ai.git





Tuesday, 8 March 2022

Python#07

Class in Python

A Class in Python is a logical grouping of data and functions. It gives the freedom to create data structures that contains arbitrary content and hence easily accessible.

Class” is a logical grouping of functions and data. Python class provides all the standard features of Object Oriented Programming.

Class inheritance mechanism :  A derived class that override any method of its base class. A method can call the method of a base class with the same name. Python Classes are defined by keyword “class” itself. Inside classes, you can define functions or methods that are part of the class

Everything in a class is indented, just like the code in the function, loop, if statement, etc.

The self argument in Python refers to the object itself. Self is the name preferred by convention by Pythons to indicate the first parameter of instance methods in Python

Python runtime will pass “self” value automatically when you call an instance method on in instance, whether you provide it deliberately or not

In Python, a class can inherit attributes and behavior methods from another class called subclass

class ametClass():
def aMethod(self):
print("Men Money Machine & Matters")

def bMethod(self, param):
print("Hey I am testing class method :" + param)

def main():
c = ametClass()
c.aMethod()
c.bMethod('I am param porul')

main()

Result:

Men Money Machine & Matters

Hey I am testing class method :I am param porul

####inheritance

class aClass():

def aMethod(self):
print('A ha : Base class method 1')

def bMethod(self, str):
print('oh oh Base class method 2 '+str)

class childClass(aClass):

def cMethod(self):
aClass.aMethod(self) # Note instance of base class method
print('A ha : Child class Method1.....')

def dMethod(self, str):
print('Oh Oh Child class method 2'+str)

def main():

c1 = aClass()
c1.aMethod() # Note child inherited from aClass
c1.bMethod('Base class ..nna') # Note child inherited from aClass

c2 = childClass()
c2.aMethod()
c2.bMethod('Besh besh Child Class Method1')
c2.cMethod()
c2.dMethod('Nanna Irukku Child Class Method 2')

main()

Result

A ha : Base class method 1

oh oh Base class method 2 Base class ..nna

A ha : Base class method 1

oh oh Base class method 2 Besh besh  Child Class Method1

A ha : Base class method 1

A ha : Child class Method1.....

Oh Oh Child class method 2Nanna Irukku Child Class Method 2

Using Constructors
# Constructors : Defining and initalizing  values

class Cadet:

name = " " # Class Variables
def __init__(self, name):
self.name = name

def printWelcome(self):
print('Welcome to Kalvi Koil, AMET '+ self.name)

Cadet1 = Cadet('Anbu')

Cadet1.printWelcome()

Result :

Welcome to Kalvi Koil, AMET  Anbu

The above sample codes explain the how to define a class, define class method, inherit a class, overloading a method, initialize the class using constructor.

Happy Learning by simple super code!

Python#06

 Python Yield

yield is not like return. When return is used it is given to caller. When yield is used you can iterate, pass or suspend. Le us see with example. Ready guys! Start.. Here you go..

Here is the situation when you should use Yield instead of Return

Use yield instead of return when the data size is large

Yield is the best choice when you need your execution to be faster on large data sets.

Use yield when you want to return a big set of values to the calling function. 

Yield is an efficient way of producing data that is big or infinite.
yield wont take memory. 

Execution is faster The yield keyword in python works like a return with the only difference is that instead of returning a value, it gives back a generator function to the caller. 

A generator is a special type of iterator that, once used, will not be available again. 

The values are not stored in memory and are only available when called.

The values from the generator can be read using for-in, list() and next() method.

The main difference between yield and return is that yield returns back a generator function to the caller and return gives a single value to the caller.

Yield does not store any of the values in memory, and the advantage is that it is helpful when the data size is big, as none of the values are stored in memory.

The performance is better if the yield keyword is used in comparison to return for large data size.

# Yield is just like return but with generator(?) objects instead of values
Generators are special functions that have to be iterated to get the values
# To get the values the
# To get the values the objects has to be iterated
#Syntax yield expression
# #Sample yield function
# def demoyield():
# yield "Welcom to AMET - Pioneer in Maritime Education"
#
# out = demoyield()
# print(out)
# #<generator object demoyield at 0x000002802AC5DA50>
# # iterate to get the value in the above object
# #Generators are functions that return an iterable generator object. The values from the generator object are fetched one at a time instead of the full list together and hence to get the actual values you can use a for-loop, using next() or list() method
# for i in out:
#.      print(i)
# Example 2
# def gen():
#       yield 'G'
#.      yield 'A'
#       yield 'N'
#       yield 'D'
#       yield 'H'
#       yield 'I'
#       yield ' '
#       yield 'M'
#       yield 'A'
#       yield 'H'
#       yield 'A'
#       yield 'N'
#
# demo = gen()
#
# for i in demo:
#.      print(i)
#
#example 3 difference between normal function and generator function
#Normal
def normalfun():
     return 'Hello Zoox Robo Taxi to Universe - normal function'
def genfun():
       yield "'Hello Zoox Robo Taxi to Universe - generator function"

print(normalfun())
print(genfun())
# Hello Zoox Robo Taxi to Universe - normal function
#until it prints the whole string normalfun()wont stop
# <generator object genfun at 0x00000298E53AD900>
#but gen iterates so we can use the generator obhject to get the values and also , 'pause' and 'resume'
print(next(genfun()))
#Note next function
print(list(genfun()))

Python#05

 File Operations in Python

How to open a file, read, print, write, append the contents.?  All shown with the following example code and output

 # Simple Excel file read


import pandas as pd

csv_file = pd.read_csv('csv.csv')

print(csv_file)


# # printed the following
# h1 h2 h3 h4
# 0 1 2 3 4
# 1 5 6 7 8
# 2 9 10 11 12
# 3 13 14 15 16
# ##################
#Excel file sheet1 reading specific

excel_file = pd.read_excel('sample.xlsx', sheet_name='Sheet1')

print(excel_file)

# Print out
# Unnamed: 0 slno name age sal
# 0 1 1 1 1 1
# 1 2 2 2 2 2
# 2 3 3 3 3 3
# 3 4 4 4 4 4
# read multiple sheets

df_sheet_multi = pd.read_excel('sample.xlsx', sheet_name=['Sheet1', 'Sheet2'])

print(df_sheet_multi)

#Printout
# {'Sheet1': Unnamed: 0 slno name age sal
# 0 1 1 1 1 1
# 1 2 2 2 2 2
# 2 3 3 3 3 3
# 3 4 4 4 4 4, 'Sheet2': Unnamed: 0 slno name age sal
# 0 1 11 11 11 11
# 1 2 22 33 44 55
# 2 3 66 66 66 66
# 3 4 77 77 77 77}

print(25*'-','Sheet1')

print(df_sheet_multi['Sheet1'])


# ------------------------- Sheet1
# Unnamed: 0 slno name age sal
# 0 1 1 1 1 1
# 1 2 2 2 2 2
# 2 3 3 3 3 3
# 3 4 4 4 4 4

print(25*'-','Sheet2')

print(df_sheet_multi['Sheet2'])


# ------------------------- Sheet2
# Unnamed: 0 slno name age sal
# 0 1 11 11 11 11
# 1 2 22 33 44 55
# 2 3 66 66 66 66
# 3 4 77 77 77 77

# To Create and write contents

f = open("demo.txt", "w")

f.write("I have written the contents!")

f.close()



#open and read the file after the appending:
f = open("demo.txt", "r")

print(f.read())

#prints => I have written the contents!
f.close()


f = open("demo.txt", "a")

f.write("Now I have written the contents more again !")

f.close()

#In demo.txt => I have written the contents!Now I have written the contents more again !

import os.path

file_exists = os.path.exists('readme.txt')

print(file_exists)

#False

import os.path

file_exists = os.path.exists('demo.txt')

print(file_exists)

#True

f = open("demo1.txt", "w")

f.write("I have written the contents!")

f.close()


f = open("demo2.txt", "w")

f.write(str(list(csv_file)))


f = open("demo2.txt","r")

print(f.read())

#f.close()

print(f.read())

#Print ['h1', 'h2', 'h3', 'h4']


Hope The above simple code snippets and printouts shown as comments is clear and understandable. Happy Open and Distance Learning!

Thursday, 24 February 2022

List & Lambda

Let us Review Python a bit and look at List & Lambda Function!

Python is the easiest popular programming language. Anything and everything you can do with python! Everyone knows about Google. Google uses Python extensively.

We learn some fundamentals by examples.

Ex.1 Print

Code

result

print("Hello, Friends!")

Hello, Friends!

Types and functions

Python automatically recognizes the types of data. Here are a few examples:

Number – Integer, Float, Complex: 3, 3.0, ‘3+j’
Character Strings: ‘ODL’, ‘AMET’
List of Objects: [10, 20, 30, 40], [‘Male’, ‘Female’]
In addition, Python has special datum meaning nothing: None

Python is rich in libraries, built-in-function. Now let us learn about variables

Ex.2 Add two constants

Code

Result

print(5+5)

10

Ex. 3 Add variables

Code

Result

X,Y = 5,5

 

print(X+Y)

10

X,Y = 5,’FIVE’

print(X+Y)

SyntaxError: invalid character '’' (U+2019)

 Note multiple assignments in a single statement

Ex. 4 Add string variables

Code

Result

X,Y = ‘5’,’5’

 

print(X+Y)

55

X,Y = ‘AMET’,’UNIVERSITY’

 

print(X+Y)

AMET University

Let us print some useful Multiplication Table

Ex 5. For loop with range -

Multiplication Table for 5: Here we use for loop with simple syntax as shown:

Code

Result

 

 

 

for x in range(1,11):

     print(x*5)

5
10
15
20
25
30
35
40
45
50

for x in range(1,11,2):

    print(x*5)

 

#Note range function (start,stop,step)

 

1
3
5
7
9 

for x in range(1,10):

 txt = '{} * {} = {}'    

 print(txt.format(x,5,x*5))

 

#note simple formatting

1 * 5 = 05
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = 30
7 * 5 = 35
8 * 5 = 40
9 * 5 = 45

 

 

For repetitive steps, we used for loop. See the syntax range. Note range (start, stop, step)

The start is inclusive and the stop is excluded with the increment step.

 Ex 6. For Loop iteration

code

result

 

for x in "AMET":

    

 print(x)

A
M
E
T

for x in ['marine’, ‘nautical science']:

    

 print(x)

marine
nautical science
 

Let us check how PVM (Python Virtual Machine) handles internally through some simulator

 

Click This Link Python Tutor - Visualize Python and paste the above code in the space given and see the steps forward.

 

 

 Ex 7. Introspection to Python variable types
#Ex 7 basic and collection variables
var_i = 5
var_f = 5.0
var_str = "AMET"
print(type(var_i))
print(type(var_f))
print(type(var_str))
print(25*'-','Collection Variables')



# Numeric collection variables
var_list = [1,2,3]
var_tuple = ("one", "two", "three")
var_set = {1,2,3}
var_dict = {"1":"one", "2": "Two", "3":"Three"}
print(type(var_list))
print(type(var_tuple))
print(type(var_set))
print(type(var_dict))

#
Result: 

<class 'int'>
<class 'float'>
<class 'str'>
------------------------- Collection Variables
<class 'list'>
<class 'tuple'>
<class 'set'>
<class 'dict'>

Happy Learning Lambda🎨😊





Work Diary - 2025

Learnt: Date Link 28.01.2025 https://ametodl.blogspot.com/p/experience-with-deepseek-...