WWW.APPSERVGRID.COM

Phorum about AppServers & Grid Technologies
It is currently Mon Dec 02, 2024 1:40 pm

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Feb 21, 2019 2:32 pm 
Offline
Site Admin

Joined: Tue Jan 25, 2011 8:51 pm
Posts: 49
Code:
#Strings
data = 'hello world'
print(data[0])
print(len(data))
print(data)

#Numbers
value=123.1
print(value)
value=10
print(value)

#Boolean
a=True
b=False
print(a,b)

a=10
b=15
print(a>b)

#Multiple Assignment
a,b,c=1,2,3
print(a,b,c)

#No value
a=None
print(a)

#If-Then-Else Conditional
value=120
if value==99:
   print('That is fast')
elif value>200:
  print("That is too fast")
else:
  print("That is safe")
 
#For-Loop
for i in range(10):
  print('Numbers:', i)
 
#While-Loop
i=0
while i<10:
  print(i)
  i+=1
 
#tuples, list, dictionaries
#tuples
a=(1,2,3)
print(a)
#list
mylist=[1,2,3]
print("Zeroth Value:", mylist[0])
mylist.append(4)
print("List Length:", len(mylist))
for value in mylist:
  print(value)
#dictionaries
mydict={'a':1,'b':2,"c":3}
print(("A value: %d")%mydict['a'])
mydict['a']=11
print(("A value: %d") % mydict['a'])
print(("Keys: %s") % mydict.keys())
print(("Values: %s") % mydict.values())
for key in mydict.keys():
  print(mydict[key])
 
#Sum function
def mysum(x,y):
  return x+y
#Test sum function
result=mysum(4,5)
print(result)

#Class
class MyClass:
    variable = "blah"
    def function(self):
        print("This is a message inside the class.")
myobjectx = MyClass()
print(myobjectx.variable)
myobjectx.function()


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron