Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Execute Python Online

def str_is(str):
    if str [:2]! ="is":
    return "is" + str
    return str
print(str_is(string))

Execute Python Online

def sum_thrice(x,y,z,):
    sum = x + y + z
    if  x == y == z:
    sum = sum * 3
    return sum
print(sum_thrice(1,2,3))
print(sum_thrice(3,3,3))

Execute Python Online

N = input()
for riga in range(N):
    for colonna in range(N):
        somma = colonna + riga
        resto = somma % 2
        if resto == 1:
            print ("X\t")
        else: 
            print ("\t")
    print ("\n")

Execute Python Online

# Hello World program in Python
n=input()
for riga in range(n):
    for colonna in range(n):
        somma=colonna+riga
        resto=somma%2
        if resto==1:
            print("x\t")
        else:
            print("\t")
    print("\n")

boards copy

source_folder = r"C:\Users\piotree\BUvsBB_BOARDZ.cfr"
dest_folder = r"C:\Users\50subset/"
boards = ['AcKdTh',
'AcKdTc',
'AcQd7h',
'AcQd7d',
'Ac4d2h',
'Ac4d2d',
'KcQd6h',
'KcQd6c',
'QcJd9h',
'QcJd9c',
'JcTd3h',
'JcTd3d',
'Qc8d6h',
'Qc8d6d',
'9c8d7h',
'9c8d7c',
'Qc7d3h',
'Qc7d3d',
'Kc4d2h',
'Tc5d4h',
'Tc5d4c',
'7c6d2h',
'7c6d2d',
'4c3d2c',
'4c3d2h',
'Jc5d5h',
'Jc5c5h',
'Ac9d8d',
'Ac9d8c',
'Kh4d2h',
'Qh9h6h',
'8c4d2h',
'Tc8d3h',
'Tc8d3c',]




for board in boards:
  xcopy_line = 'xcopy '+ source_folder.replace('BOARDZ', board)+ ' '+ dest_folder
  print(xcopy_line)

boards

source_folder = r"C:\Users\piotree\BUvsBB_B0ARD.cfr"
dest_folder = r"C:\Users\50subset/"
boards = ['AcKdTh',
'AcKdTc',
'AcQd7h',
'AcQd7d',
'Ac4d2h',
'Ac4d2d',
'KcQd6h',
'KcQd6c',
'QcJd9h',
'QcJd9c',
'JcTd3h',
'JcTd3d',
'Qc8d6h',
'Qc8d6d',
'9c8d7h',
'9c8d7c',
'Qc7d3h',
'Qc7d3d',
'Kc4d2h',
'Tc5d4h',
'Tc5d4c',
'7c6d2h',
'7c6d2d',
'4c3d2c',
'4c3d2h',
'Jc5d5h',
'Jc5c5h',
'Ac9d8d',
'Ac9d8c',
'Kh4d2h',
'Qh9h6h',
'8c4d2h',
'Tc8d3h',
'Tc8d3c',]




for board in boards:
  xcopy_line = 'xcopy '+ source_folder.replace('B0ARD', board)+ ' '+ dest_folder
  print(xcopy_line)

Python Class Inheritance

#!/usr/bin/python

class Parent:        # define parent class
   parentAttr = 100
   def __init__(self):
      print "Calling parent constructor"

   def parentMethod(self):
      print 'Calling parent method'

   def setAttr(self, attr):
      Parent.parentAttr = attr

   def getAttr(self):
      print "Parent attribute :", Parent.parentAttr
      
class Parent2:
    parentAttr = 300
    
    def parentMethod(self):
        print "Calling parent2 method"
        
    def setAttr(self, attr):
        Parent2.parentAttr = attr
        
    def getAttr(self):
        print Parent2.parentAttr

class Child(Parent,Parent2): # define child class
   def __init__(self):
      print "Calling child constructor"

   def childMethod(self):
      print 'Calling child method'

c = Child()          # instance of child
c.childMethod()      # child calls its method
c.parentMethod()     # calls parent's method
#c.setAttr(200)       # again call parent's method
c.getAttr()          # again call parent's method

ggkk

# Hello World program in Python
    
print "Hello World!\n"

Execute Python Online

# Hello World program in Python
a=input()
b=input()
c=a*b
print (c)"\n"

Execute Python Online

print("hello world")

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.