7 views

Uploaded by Theodor Munteanu

Basic elements presented only through examples:
Printing
Strings,Lists,tuples
Loops:While and For
Functions

- Functions
- Intro to R Lecture 1
- ALV Report
- All the Tables in SAP MM
- yuitest
- How to Purge Sale Order Records in Order Management
- intro to functions.pdf
- Jasper Reports Using Struts2
- Implementation of Emtp Atp Software in the Study of Electromagnetic Transient Phenomenon
- SIMATIC S7 Function Description Www.otomasyonegitimi.com
- Functions S10
- How to Create Custom Employee Number Generation via Fast Formula
- Name Spaces
- Procedures and Scope Reading
- Framework Interceptors Struts2
- Position_Budgeting.pdf
- Stored Procedures
- apexins
- Perl Interview
- Lottery program written in Assembly

You are on page 1of 6

1.Printing

Test1.py

print("Hello,Theodor")

print("What are you doing?")

days='Monday','Tuesday','Wednesday'

print(days)

paragraph = """This is a paragraph.It is

made up of multiple lines and sentences."""

print(paragraph)

word='word'

sentence="This is a sentence."

print(word,sentence)

Test2.py

counter=100

miles=1000.0 #a floating point

name="John" #a string

print (counter)

print (miles)

print (name)

print(name,miles)

a,b,c=1,2,"john"

print(a,b,c)"""

"""str='Hello world!'

print (str) #Prints complete string

print (str[0]) #Prints first character

print (str[2:5])

print (str[2:]) #Prints string starting from 3rd character

print (str*2) # Prints string two times

print (str + "TEST") # Prints concatenated string"""

"part two"

list=['abcd',123,1.2,'theodor',11.2]

print (list)

print(list[0])

print (list[1:3])

print (list[2:])

print (list * 2)

"part three"

tuple=('abcd',700,2.1,'john',1.2)

list =['abcd',700,2.1,'john',1.2]

"part three"

dict = {}

dict['one'] = "This is one"

dict[2] = "This is two"

print (dict['one']) # Prints value for 'one' key

print (dict[2]) # Prints value for 2 key

print (tinydict) # Prints complete dictionary

print (tinydict.keys()) # Prints all the keys

print (tinydict.values()) # Prints all the values

Test3.py

"OPERATORS"

"PART 1--Comparison"

a=21

b=10

c=0

if(a==b):

print("Line 1 - a is equal to b")

else:

print("Line 1 - a is not equal to b")

if(a!=b):

print ("Line 2 - a is not equal to b")

else:

print ("Line 2 - a is equal to b")

a=5;

b=20;

if(a<=b):

print ("Line 3 - a is either less than or equal to b")

else:

print ("Line 3 - a is neither less than nor equal to b")

a=21;b=10;c=0

c=a+b

print("Line 1 - Value of c is ",c)

c=a*b;print("Line 3 - Value of c is ",c)

if(b%a==1):

print(b,"is an odd number")

else:

print(b,"is an even number")

a=5;b=6;c=a**b;d=a*b

print("the value of c is",c,"and the value of d is ",d)

a=100

if a:

print("1-Got a true expression value")

print (a)

else:

print("1-Got a false expression value")

print(a)

count = 0

while(count<9):

print ('The count is:',count)

count=count+1

print("Good bye!")

Test4.py

"part 1"

var=1

while (var<=3):

num=input("Enter a number :")

print("You entered:",num)

var=var+1

var=1

while(var<=3):

num=input("Enter a number:")

print("You entered:",num)

var=var+1

else:

print("The while loop is ove")

var=2

while(var<=5):

num=input("Enter a number:")

print(var,"is smaller or equal to 5")

var=var+1

else:

print(var,"is greater than 5")

"part 2"

"print("cmp(80,-100)",cmp(80,-100))#the same"""

import math

print("math.fabs(-45.17)",math.fabs(-45.17))

print("math.fabs(math.pi): ",math.fabs(math.pi))

print(math.pow(100,2))

print(math.ceil(2.1))

print(round(21.2222,2))

print(math.modf(2.12))# produces the fractional and the integer part of the

#number in this order

var1='Hello everybody!'

var2="Python programming"

print("var1[0]: ",var1[0])

print ("var2[1:5]: ",var2[1:5])

print("Hello your name is %s and you are %d years old"%('Rico',21))

"Strings---continuation"

"Capitalization"

str="this is a string"

print(str.capitalize())

str = "this is string example....wow!!!";

print ("str.center(40, 'a') : ", str.center(40, 'a'))

print(str.center(30,'b')) #this leaves the string unchanged because the

length

#of str is greater than 40

import time

localtime=time.localtime(time.time())

print(localtime)

#the result of display is time.struct_time(tm_year=2017, tm_mon=2, tm_mday=9,

#tm_hour=21, tm_min=54, tm_sec=59, tm_wday=3, tm_yday=40, tm_isdst=0)

localtime=time.asctime(time.localtime(time.time()))

print(localtime)

import calendar

cal=calendar.month(2008,1)

print("here is the calendar:",cal)

here is the calendar: January 2008

Mo Tu We Th Fr Sa Su

1 2 3 4 5 6

7 8 9 10 11 12 13

14 15 16 17 18 19 20

21 22 23 24 25 26 27

28 29 30 31

"Functions"

"In order to declare a function we must use the keyword def"

def printme(str):

print(str)

return;

printme(str="theodor")

def printinfo(name,age):

print("Name:",name)

print("Age:",age)

return;

printinfo(age=50,name="theodor")

def printinfo(name,age=30):

print("Name: ",name)

print("Age: ",age)

return;

printinfo(name="lucas")

def printinfo( arg1, *vartuple ):

"This prints a variable passed arguments"

print ("Output is: ")

print (arg1)

for var in vartuple:

print (var)

return;

printinfo( 10 )

printinfo( 70, 60, 50 )

10

And

70

60

50

"Anonymous functions"

sum=lambda arg1,arg2:arg1+arg2-1;

print("Value of total : ",sum(10,20)) #prints:Value of total: 29

print("Value of total 2: ",sum(20,20)) # prints:Value of total : 39

def sum(arg1,arg2):

total=arg1+arg2

print ("Inside the function: ",total)

return total;

total=sum(10,20);

print("Outside the function : ",total)

"Scope"

total = 0; # This is global variable.

# Function definition is here

def sum( arg1, arg2 ):

# Add both the parameters and return them."

total = arg1 + arg2; # Here total is local variable.

print ("Inside the function local total : ", total)

return total;

sum( 10, 20 );

print ("Outside the function global total : ", total)

"For loops"

print('Current Letter :',letter)

fruits=['oranges','strawberry','mango']

for fruit in fruits:

print('Current fruit: ', fruit)

fruits=['banana','apple','mango']

for index in range(len(fruits)):

print ('Current fruit :',fruits[index])

s=0

for i in range(1,6):

s=s+i

print (s)#it prints the sum of the first 6-1 elements since range (a,b)

#is seen as the half-open interval [a,b)

"Lists"

list1=['the','most','beautiful']

print(list1)

del list1[1]

print(list1)

list2=[1,2,3,4,5,6,7];

print(list2[0]) # prints 1

print(list2[1:4]) # prints a slice of the list,namely 2 3 4 5

"length"

print (len([1,2,3]))

list=[1,2,3]+[2,3,4] # concatenates two lists

print(list)

list=[1,2]

print(list*2) # appears two times the list 1 2

for x in [1,2,3]:print(x)# prints on each row an element

list=list*3

print(list)# the list repeats itself 3 times

print(list[1:])# starting with the 2nd position it prints all elements

l1,l2=['xyz','zara','abc'],[456,700,200]

print("Max value element : ",max(l1))

print("Min value element : ",min(l2))

#If l1 would be [12,'xyz','zara','abc'] the maximum would not be supported

#because there is no comparison relation between string and int

- FunctionsUploaded byPetros Gavai
- Intro to R Lecture 1Uploaded byDanny DeWitt
- ALV ReportUploaded byMayur Odedara
- All the Tables in SAP MMUploaded byBasu Gudageri
- yuitestUploaded byJoyhill
- How to Purge Sale Order Records in Order ManagementUploaded byArijit Nath
- intro to functions.pdfUploaded bySuhniAbbasi
- Jasper Reports Using Struts2Uploaded byrammca27
- Implementation of Emtp Atp Software in the Study of Electromagnetic Transient PhenomenonUploaded bysoumya
- SIMATIC S7 Function Description Www.otomasyonegitimi.comUploaded bywww.otomasyonegitimi.com
- Functions S10Uploaded byJoe KL
- How to Create Custom Employee Number Generation via Fast FormulaUploaded bySaquib.Mahmood
- Name SpacesUploaded bydeepapadhi
- Procedures and Scope ReadingUploaded byAnnie Nguyen
- Framework Interceptors Struts2Uploaded bylazulimashal
- Position_Budgeting.pdfUploaded bymohamed-mof
- Stored ProceduresUploaded bySathyamurthy Duraikkannu
- apexinsUploaded byShaik Abbas
- Perl InterviewUploaded byBhaskar Ramarao
- Lottery program written in AssemblyUploaded byReynaldo José Ramírez
- userproc.psUploaded bysrrhce
- DataAccessHandbook_CH05Uploaded bysantosh_aditya
- idftf svmUploaded byChirag Mandot
- Create a Quiz Application Using AS3 ClassesUploaded byharishfriendz
- develop3.1Uploaded byredoctober24
- ITE 407_LAB_EX_4_03282017_wk8Uploaded byDalia Asti
- Functions in cUploaded byPS Radhika
- Mme Commands DocummentUploaded byAnonymous jF8rU5
- ad_training_Course_User_Subroutines.pdfUploaded byGonzalo Anzaldo
- horse7Uploaded byRahul Jaiswal

- Double Barrier Options PricingUploaded byTheodor Munteanu
- How Much Costs a Nobel Peace PrizeUploaded byTheodor Munteanu
- Implied Risk Premia and Factor AllocationUploaded byTheodor Munteanu
- Italian for BeginnersUploaded byTheodor Munteanu
- Risky Bonds and CDS Valuation in PythonUploaded byTheodor Munteanu
- Numerical Methods for Solutions of Equations in PythonUploaded byTheodor Munteanu
- French Language Build-upUploaded byTheodor Munteanu
- Recursive LU Factorization of a Matrix in PythonUploaded byTheodor Munteanu
- Stochastic Calculus for Finance(Exam 7)Uploaded byTheodor Munteanu
- Stochastic Calculus for Finance (Exam 5)Uploaded byTheodor Munteanu
- UN BlacklistUploaded byTheodor Munteanu
- The Article (Deutschen Artikle)Uploaded byTheodor Munteanu
- Numerical Methods to Solve Systems of Equations in PythonUploaded byTheodor Munteanu
- Probability Distributions in PythonUploaded byTheodor Munteanu
- Financial Engineering in PythonUploaded byTheodor Munteanu
- Financial accounting (Stage 6)Uploaded byTheodor Munteanu
- Final Assigment - Taib.pdfUploaded byTheodor Munteanu
- Financial Accounting and AnalysisUploaded byTheodor Munteanu
- Stochastic Calculus for Finance (Exam 8)Uploaded byTheodor Munteanu
- Stochastic Calculus for Finance(Exam 4)Uploaded byTheodor Munteanu
- Financial Accounting and Analysis(Stage 4)Uploaded byTheodor Munteanu
- Stochastic Calculus for Finance(Exam 2)Uploaded byTheodor Munteanu
- Stochastic Calculus for Finance (Exam 9)Uploaded byTheodor Munteanu
- Stochastic Calculus for Finance (Exam 11)Uploaded byTheodor Munteanu
- Stochastic Calculus for Finance(Exam 10)Uploaded byTheodor Munteanu
- Stochastic Calculus for Finance (Exam 3)Uploaded byTheodor Munteanu
- Financial Analysis and Accounting(Stage 5)Uploaded byTheodor Munteanu
- Stochastic Calculus for Finance(Exam 6)Uploaded byTheodor Munteanu
- Stochastic Calculus for Finance(Exam 1)Uploaded byTheodor Munteanu
- Financial Accounting and Analysis (Stage 2)Uploaded byTheodor Munteanu

- Thermal StreesUploaded byRoberth Sallago Espinoza
- Exam18 ICSE Sample Paper Maths (2)Uploaded byAna Iyer
- Antibiotic.docxUploaded byVinayKumar
- Groper, Morel_ Klebanov, Boris M-Power mechanisms of rotational and cyclic motions-CRC Press (2016).pdfUploaded byHarry
- Neuromarketing en Accion Spanish Edition by Nestor BraidotUploaded byLesly Parra Suzaño
- chapter1-RLCCircuitsUploaded byMohan Reddy
- An Energy-dispersive Technique to Measure X-ray Coherent Scattering Form Factors of Amorphous MaterialsUploaded byAhmet Krykevic
- robyn urive resumeUploaded byapi-363318548
- Ch6 Mental HealthUploaded byqihong
- StatisticsUploaded byJun Man
- Critical AnalysisUploaded byashvin
- antioksidantUploaded byRudi haris munandar
- In a Different Key by John Donvan & Caren Zucker-ExcerptUploaded byCrown Publishing Group
- Geostatistical Design of Infill Drilling ProgramsUploaded byminerito2211
- ITB (Institut Teknologi Brunei) Timetable Petroleum and Chemical Engineering August 2013Uploaded bysk8teroy
- [R. S. Koppen] Virginia Woolf, Fashion, And Litera(BookFi.org)Uploaded byAimee Bennett
- cpu_0605Uploaded byd7cftgPtLMXIeVbW7VZB
- 0500_s06_ms_1Uploaded bySochima Nwobia
- SmartStrike Map Card Accessory ManualUploaded byfractalbops138
- outline essay 2Uploaded byapi-384952641
- Production RatesUploaded bySam Monte
- Rpp Kelas Xii Smt 2Uploaded byRierieinginditemani Olehcintamuyangsuci
- DIHR ICAR National Action Plans NAPs Report3Uploaded byJordi Jaumà
- 0fb4316bfad4d25845463d09b50df862870065d63b6688509e44332a93a31cb9Uploaded byOana
- d_342_id-510.pdfUploaded byWellington Analuisa
- Renew EnergyUploaded byCheku Dojee
- dairy technology updateUploaded bysubhendujena
- ADA553561.pdfUploaded byafri yanto
- CharterNetFirmProfile.2014Uploaded byAnonymous 2sdpF7vV
- 1-ANTIHYPERLIPIDEMICSUploaded byChristian Villacruzes