This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python -tt | |
# Copyright 2010 Google Inc. | |
# Licensed under the Apache License, Version 2.0 | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# Google's Python Class | |
# http://code.google.com/edu/languages/google-python-class/ | |
# Basic list exercises | |
# Fill in the code for the functions below. main() is already set up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python -tt | |
# Copyright 2010 Google Inc. | |
# Licensed under the Apache License, Version 2.0 | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# Google's Python Class | |
# http://code.google.com/edu/languages/google-python-class/ | |
# Additional basic list exercises |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python -tt | |
# Copyright 2010 Google Inc. | |
# Licensed under the Apache License, Version 2.0 | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# Google's Python Class | |
# http://code.google.com/edu/languages/google-python-class/ | |
# Basic string exercises | |
# Fill in the code for the functions below. main() is already set up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2.4 -tt | |
# Copyright 2010 Google Inc. | |
# Licensed under the Apache License, Version 2.0 | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# Google's Python Class | |
# http://code.google.com/edu/languages/google-python-class/ | |
# Additional basic string exercises |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__INIT__: | |
The name __init__ is essentially reserved in python , special function or method.What's special about it ? Creates space in memory or initialzes | |
for class to remeber details of class attributes or variables. | |
class movie(): | |
def __init__(self,title,story): | |
self.title = "hero" | |
self.storyline = "drama" | |
somehow initialize these variable(title,story) with information init is going to receive.And in particular it is going to receive the information while |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
,Regex summary and examples | |
. - any charcter except newline | |
\d - Digit(0-9) | |
\D - Not a digit(0-9) | |
\w - word charcter(a-z, A-Z,0-9,_) | |
\W- not a word charcter | |
\s - whitespace(space , tab, newline) | |
\S - not a whitespace(space , tab , newline) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python2 --Range | |
1.It produces a list for itertions. | |
For x in range(3): | |
print x | |
O/p: | |
0 | |
1 | |
2 | |
y = range(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Basic Examples: | |
1.{ x^2: x is a natural number less than 10 } | |
[x*2 for x in range(0,10)] | |
2.{ x: x is a whole number less than 20, x is even } | |
[x for x in range(0,20) if x%2 == 0] | |
3.{ x: x is an alphabet in word ‘MATHEMATICS’, x is a vowel } | |
[x for x in "MATHEMATICS" x not in "AEIOU"] | |
======================================================================================= | |
The same gets implemented in a simple LC construct in a single line as: | |
[ output_expression() for(set of values to iterate) if(conditional filtering) ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
#Opening the file | |
f0 = open("out.txt","rw+") #File containing the original testing report. | |
f1 = open("new.txt","rw+") #File containg the report in string format | |
f2 = open("new3.txt","rw+")#File containing the required fields in string format | |
f3 = open("book2.csv","w+")#csv file with the value for keys | |
#function to remove whitespaces from file out.txt and writing it in new.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mary had a little lambda, | |
as pure as snow | |
For every Program Mary wrote, | |
the lambda was all she needed to know |
OlderNewer