Best Python code snippet using fMBT_python
factura.py
Source:factura.py  
1import os2from PyFPDF import FPDF3pdf = FPDF()4pdf.AddPage()5pdf.SetFont('arial', '', 13.0)6pdf.SetXY(105.0, 8.0)7pdf.Cell(ln=0, h=22.0, align='C', w=75.0, txt='Comprobante de Ejemplo', border=0)8pdf.SetLineWidth(0.0)9pdf.Rect(15.0, 15.0, 170.0, 245.0)10pdf.SetLineWidth(0.0)11pdf.Rect(95.0, 15.0, 10.0, 10.0)12pdf.Image('serpiente.png', 20.0, 17.0, link='', type='', w=13.0, h=13.0)13pdf.SetFont('arial', 'B', 16.0)14pdf.SetXY(95.0, 18.0)15pdf.Cell(ln=0, h=2.0, align='C', w=10.0, txt='X', border=0)16pdf.SetFont('arial', '', 8.0)17pdf.SetXY(105.0, 21.0)18pdf.Cell(ln=0, h=4.0, align='C', w=75.0, txt='Original', border=0)19pdf.SetFont('arial', 'B', 7.0)20pdf.SetXY(95.0, 21.5)21pdf.Cell(ln=0, h=4.5, align='C', w=10.0, txt='COD.00', border=0)22pdf.SetLineWidth(0.0)23pdf.Line(100.0, 25.0, 100.0, 57.0)24pdf.SetFont('arial', 'B', 14.0)25pdf.SetXY(125.0, 25.5)26pdf.Cell(ln=0, h=9.5, align='L', w=60.0, txt='00000001', border=0)27pdf.SetXY(115.0, 27.5)28pdf.Cell(ln=0, h=5.5, align='L', w=10.0, txt='N\xba: ', border=0)29pdf.SetFont('arial', 'B', 12.0)30pdf.SetXY(17.0, 32.5)31pdf.Cell(ln=0, h=5.0, align='L', w=98.0, txt='EMPRESA', border=0)32pdf.SetFont('arial', '', 12.0)33pdf.SetXY(115.0, 33.0)34pdf.Cell(ln=0, h=7.0, align='L', w=60.0, txt='Fecha:', border=0)35pdf.SetXY(135.0, 33.0)36pdf.Cell(ln=0, h=7.0, align='L', w=40.0, txt='19/02/2009', border=0)37pdf.SetLineWidth(0.0)38pdf.Line(15.0, 57.0, 185.0, 57.0)39pdf.SetFont('arial', '', 10.0)40pdf.SetXY(17.0, 59.0)41pdf.Cell(ln=0, h=6.0, align='L', w=13.0, txt='Sr.(s):', border=0)42pdf.SetXY(35.0, 59.0)43pdf.Cell(ln=0, h=6.0, align='L', w=140.0, txt='Mariano Reingart', border=0)44pdf.SetXY(17.0, 64.0)45pdf.Cell(ln=0, h=6.0, align='L', w=18.0, txt='Domicilio:', border=0)46pdf.SetXY(35.0, 64.0)47pdf.Cell(ln=0, h=6.0, align='L', w=125.0, txt='Siempreviva 12345', border=0)48pdf.SetXY(17.0, 69.0)49pdf.Cell(ln=0, h=6.0, align='L', w=18.0, txt='Tel\xe9fono:', border=0)50pdf.SetXY(35.0, 69.0)51pdf.Cell(ln=0, h=6.0, align='L', w=80.0, txt='+1-5555-5555', border=0)52pdf.SetXY(115.0, 69.0)53pdf.Cell(ln=0, h=6.0, align='L', w=18.0, txt='Localidad:', border=0)54pdf.SetXY(133.0, 69.0)55pdf.Cell(ln=0, h=6.0, align='L', w=42.0, txt='Springfield', border=0)56pdf.SetLineWidth(0.0)57pdf.Line(15.0, 77.0, 185.0, 77.0)58pdf.SetXY(17.0, 80.0)59pdf.Cell(ln=0, h=5.0, align='L', w=15.0, txt='IVA:', border=0)60pdf.SetXY(35.0, 80.0)61pdf.Cell(ln=0, h=5.0, align='L', w=70.0, txt='Responsable', border=0)62pdf.SetXY(115.0, 80.0)63pdf.Cell(ln=0, h=5.0, align='L', w=20.0, txt='CUIT:', border=0)64pdf.SetXY(135.0, 80.0)65pdf.Cell(ln=0, h=5.0, align='L', w=40.0, txt='10-12345678-9', border=0)66pdf.SetLineWidth(0.0)67pdf.Line(15.0, 88.0, 185.0, 88.0)68pdf.SetXY(17.0, 90.0)69pdf.Cell(ln=0, h=5.0, align='L', w=48.0, txt='Fecha de Vencimiento Pago:', border=0)70pdf.SetXY(65.0, 90.0)71pdf.Cell(ln=0, h=5.0, align='L', w=20.0, txt='23/07/1978', border=0)72pdf.SetXY(92.0, 90.0)73pdf.Cell(ln=0, h=5.0, align='L', w=43.0, txt='Per\xedodo Facturado', border=0)74pdf.SetXY(125.0, 90.0)75pdf.Cell(ln=0, h=5.0, align='L', w=20.0, txt='01/01/2009', border=0)76pdf.SetXY(150.0, 90.0)77pdf.Cell(ln=0, h=5.0, align='L', w=20.0, txt='31/01/2009', border=0)78pdf.SetLineWidth(0.0)79pdf.Line(15.0, 95.0, 185.0, 95.0)80pdf.SetLineWidth(0.0)81pdf.Line(155.0, 95.0, 155.0, 230.0)82pdf.SetXY(20.0, 97.0)83pdf.Cell(ln=0, h=5.0, align='L', w=125.0, txt='Descripci\xf3n', border=0)84pdf.SetXY(160.0, 97.0)85pdf.Cell(ln=0, h=5.0, align='R', w=20.0, txt='Importe', border=0)86pdf.SetLineWidth(0.0)87pdf.Line(15.0, 102.0, 185.0, 102.0)88pdf.SetXY(20.0, 103.0)89pdf.Cell(ln=0, h=7.0, align='L', w=125.0, txt='Esto es una prueba y no es v\xe1lido como factura', border=0)90pdf.SetXY(160.0, 103.0)91pdf.Cell(ln=0, h=7.0, align='R', w=20.0, txt='100,00', border=0)92pdf.SetLineWidth(0.0)93pdf.Line(15.0, 230.0, 185.0, 230.0)94pdf.SetXY(20.0, 233.0)95pdf.Cell(ln=0, h=5.0, align='L', w=95.0, txt='CAE N\xba', border=0)96pdf.SetXY(45.0, 233.0)97pdf.Cell(ln=0, h=5.0, align='L', w=30.0, txt='01234567890', border=0)98pdf.SetFont('arial', '', 12.0)99pdf.SetXY(105.0, 234.0)100pdf.Cell(ln=0, h=9.0, align='R', w=45.0, txt='NETO GRAVADO:', border=0)101pdf.SetFont('arial', 'B', 12.0)102pdf.SetXY(145.0, 234.0)103pdf.Cell(ln=0, h=9.0, align='R', w=33.0, txt='100,00', border=0)104pdf.SetFont('arial', '', 10.0)105pdf.SetXY(20.0, 238.0)106pdf.Cell(ln=0, h=5.0, align='L', w=95.0, txt='Fecha Vto. CAE:', border=0)107pdf.SetXY(55.0, 238.0)108pdf.Cell(ln=0, h=5.0, align='L', w=30.0, txt='19/02/2009', border=0)109pdf.SetFont('arial', '', 12.0)110pdf.SetXY(125.0, 241.0)111pdf.Cell(ln=0, h=9.0, align='R', w=25.0, txt='IVA 21%:', border=0)112pdf.SetFont('arial', 'B', 12.0)113pdf.SetXY(145.0, 241.0)114pdf.Cell(ln=0, h=9.0, align='R', w=33.0, txt='21,00', border=0)115pdf.Interleaved2of5('012345678905', 20.0, 243.5, w=0.75)116pdf.SetFont('arial', 'B', 12.0)117pdf.SetXY(105.0, 251.0)118pdf.Cell(ln=0, h=9.0, align='R', w=73.0, txt='121,00', border=0)119pdf.SetFont('arial', '', 12.0)120pdf.SetXY(125.0, 251.0)121pdf.Cell(ln=0, h=9.0, align='R', w=25.0, txt='Total:', border=0)122pdf.SetLineWidth(0.0)123pdf.Rect(155.0, 252.0, 25.0, 7.0)124pdf.SetFont('arial', '', 10.0)125pdf.SetXY(20.0, 253.0)126pdf.Cell(ln=0, h=7.0, align='L', w=120.0, txt='012345678905', border=0)127pdf.Output('c:/factura.pdf', 'F')...sheep.py
Source:sheep.py  
1import turtle2import time3import math as m4class Sheep(object):5    def __init__(self,xsize):6        self.t = turtle.Turtle()7        self.xsize = xsize8        t = self.t9        # ç»ç¬è®¾ç½®10        t.screen.screensize(canvwidth=1000,canvheight=500,bg='white')11        t.pensize(2)12        t.speed(10)13        # t.hideturtle()14        #åå§åç»ç¬ä½ç½®15        t.penup()16        t.setpos(self.xsize,0)17        t.pendown()18    # 设置ç»ç¬åæ 19    def setxy(self,x,y):20        t = self.t21        t.penup()22        pos_x = t.position()[0]23        pos_y = t.position()[1]24        t.setpos(pos_x + x,pos_y + y)25        t.pendown()26    def create_sheep(self):27        t = self.t28        # ç¾å¤´29        self.setxy(-200,0)30        t.fillcolor('black')31        t.begin_fill()32        t.circle(100)33        t.end_fill()34        # ç¼ç35        # ç¼ç½36        print(t.position())37        self.setxy(-20,120)38        t.fillcolor('white')39        t.begin_fill()40        t.seth(45)41        t.circle(18,-280)42        t.seth(45)43        t.circle(-20,292)44        t.end_fill()45        # ç¼ç 46        self.setxy(3,12)47        t.fillcolor('black')48        t.begin_fill()49        t.seth(85)50        t.circle(10)51        t.seth(85)52        t.circle(-10)53        t.end_fill()54        # ç¼å¿55        t.fillcolor('white')56        t.begin_fill()57        t.seth(85)58        t.circle(3)59        t.seth(85)60        t.circle(-3)61        t.end_fill()62        # å´63        self.setxy(0,-100)64        t.color('red')65        t.seth(300)66        t.forward(8)67        self.setxy(-1, 3)68        t.seth(0)69        t.circle(80,60)70        self.setxy(2, -2)71        t.seth(145)72        t.forward(8)73        t.color('black')74        # è³æµ75        self.setxy(-145,120)76        p1 = t.position()77        t.fillcolor('black')78        t.begin_fill()79        t.seth(0)80        t.circle(-120,20)81        p2 = t.position()82        t.setpos(p1)83        t.seth(60)84        t.circle(-30,120)85        t.goto(p2)86        t.end_fill()87        # 身ä½88        self.setxy(41,12)89        t.seth(45)90        t.circle(-150,100)91        t.pensize(5)92        t.seth(0)93        t.circle(-120,30)94        t.seth(60)95        t.circle(-15,320)96        t.seth(330)97        t.circle(-80,180)98        t.seth(210)99        t.circle(-80,90)100        #4æ¡è
¿101        t.pensize(2)102        for leg in range(4):103            self.setxy(8+15*leg,0)104            t.seth(270)105            t.forward(80)106            t.seth(0)107            t.forward(8)108            t.seth(90)109            t.forward(80)110        #è111        self.setxy(-200,-80)112        p3 = t.position()113        t.color('green')114        t.fillcolor('green')115        t.begin_fill()116        t.seth(120)117        t.forward(30)118        t.seth(330)119        t.forward(30)120        t.seth(60)121        t.forward(40)122        t.seth(260)123        t.forward(45)124        t.setpos(p3)125        t.end_fill()126if __name__ == '__main__':127    for x in (0,350):128        sheep = Sheep(x)129        sheep.create_sheep()...main.py
Source:main.py  
1from PCD8544 import PCD85442import lcd_gfx3from ntc import *4import time5from machine import Pin, Timer6led = Pin(25, Pin.OUT, value=1)7# """8r=Pin(10, Pin.OUT, value=0)9IRQ_RISING_FALLING = Pin.IRQ_RISING | Pin.IRQ_FALLING10def mkey(l):11    r.value( 0 if key_menu.value() else 1)12#     print(l)13    print("pin=%d key=%d" % (r.value(), (key_menu.value())))14#     print(key_menu.value())15timer = Timer()16def debounce(pin):17    timer.init(mode=Timer.ONE_SHOT, period=50, callback=mkey)18key_menu=Pin(13, Pin.IN, Pin.PULL_UP)19key_menu.irq(debounce, IRQ_RISING_FALLING)20# """21VREF=2.522ntc0=NTC(adc=ADC(Pin(26)), R=2960, Ro=47000, beta=3740, V=VREF, Vref=VREF)23ntc1=NTC(adc=ADC(Pin(27)), R=2960, Ro=47000, beta=3740, V=VREF, Vref=VREF)24ntc2=NTC(adc=ADC(Pin(28)), R=9860, Ro=90500, beta=3950, V=VREF, Vref=VREF)25adc=ADC(Pin(29))26d = PCD8544(spi_id=0, dc=17, din=19, clk=18, dout=16, rst=20)27print(d._spi)28d.begin()29# 30# d.p_string("Start ")31# d.display()32# time.sleep(1)33# d.init()34# d.LClear()35dot=""36while 1:37    d.LClear()38    d.setxy(0,0)39    d.LPrint ("{:.3f}V".format(ntc0.in_volt()))40    d.setxy(7,0)41    d.LPrint ("{:.3f}V ".format(ntc1.in_volt()))42    r0=ntc0.r_DN()43    d.setxy(0,1)44    d.LPrint("{:.2f}K".format(r0/1000)) 45    r1=ntc1.r_DN()46    d.setxy(7,1)47    d.LPrint("{:.2f}K".format(r1/1000))48    d.setxy(0,2)49    d.LPrint("{:.1f}C".format(ntc0.to_temp(ntc0.r_DN())))50    d.setxy(7,2)51    d.LPrint("{:.1f}C".format(ntc1.to_temp(ntc1.r_DN())))52    d.setxy(0,4)53    d.LPrint("{:3.1f}C".format(ntc2.to_temp(ntc2.r_DN())))54    r2=ntc2.r_DN()55    d.LPrint(" {:.2f}K".format(r2/1000))56    d.setxy(0,5)57    if len(dot)>=14:58        dot=""59    dot += "."60    d.LPrint(dot)61#    d.display()62    d.setxy(3,3)63    d.LPrint("*" if r.value() else ". ")64#     d.LPrint(" {}".format(adc.read_u16()))65    led.value( 0 if led.value() else 1)66#     print("%d %d" % (r.value(), key_menu.value()))...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
