Best Python code snippet using hypothesis
payment_dialog.py
Source:payment_dialog.py  
...129        self.misc_payment_widget = MiscPaymentWidget(self)130        self.set_advanced_but_text(_("unusual payments"))131        self.add_advanced_widget(self.misc_payment_widget)132        self.misc_payment_widget.updated.connect(self.update_totals)133    def int_to_decimal(self, i):134        assert isinstance(i, int), \135            "input must be an integer, not %s, (%s)" % (i, type(i))136        ss = str(i)137        negative = "-" if "-" in ss else ""138        ss = ss.strip("-")139        if len(ss) == 0:140            return "0.00"141        if len(ss) == 1:142            return "%s0.0%s" % (negative, ss)143        if len(ss) == 2:144            return "%s0.%s" % (negative, ss)145        return "%s%s.%s" % (negative, ss[:-2], ss[-2:])146    def update_totals(self, *args):147        self.cash_tot_label.setText(self.int_to_decimal(self.cash_total))148        self.cheque_tot_label.setText(self.int_to_decimal(self.cheque_total))149        self.card_tot_label.setText(self.int_to_decimal(self.card_total))150        self.tx_tot_label.setText(self.tx_total_text)151        self.sundries_tot_label.setText(self.sundry_total_text)152        self.grand_tot_label.setText(self.grand_total_text)153    def set_treatment_default_amount(self, amt):154        if amt > 0:155            self.default_tx_amount = self.int_to_decimal(amt)156    @property157    def hdp(self):158        return self.misc_payment_widget.hdp_value159    @property160    def other(self):161        return self.misc_payment_widget.other_value162    @property163    def refund(self):164        return self.misc_payment_widget.refund_value165    @property166    def grand_total(self):167        val = (self.cash_total + self.cheque_total +168               self.card_total + self.hdp + self.other + self.refund)169        self.enableApply(val != 0 or self.refund != 0)170        return val171    @property172    def tx_total_text(self):173        return self.int_to_decimal(self.tx_total + self.hdp)174    @property175    def sundry_total_text(self):176        return self.int_to_decimal(self.sundries_total + self.other)177    @property178    def grand_total_text(self):179        return self.int_to_decimal(self.grand_total)180    @property181    def other_text(self):182        return self.int_to_decimal(self.other)183    @property184    def refund_text(self):185        return self.int_to_decimal(self.refund)186    @property187    def cash_total(self):188        return self.cash_le.pence_value + self.cash_sundries_le.pence_value189    @property190    def cheque_total(self):191        return self.cheque_le.pence_value + self.cheque_sundries_le.pence_value192    @property193    def card_total(self):194        return self.card_le.pence_value + self.card_sundries_le.pence_value195    @property196    def sundries_total(self):197        return self.sundry_cash + self.sundry_cheque + self.sundry_card198    @property199    def tx_total(self):...utils.py
Source:utils.py  
...38    return int_to_list(x_int, bytes, endian)39def list_to_decimal(x, bytes=4, endian='little'):40    x_int = list_to_int(x, endian=endian)41    # print('x_int: %d' % x_int)42    return int_to_decimal(x_int,bytes)43def int_to_decimal(x, bytes=4):44    if bytes == 4:45        x_bytes = struct.pack('I',x)46        (x_float,) = struct.unpack('f',x_bytes)47    elif bytes == 8:48        x_bytes = struct.pack('Q',x)49        (x_float,) = struct.unpack('d',x_bytes)50    else:51        print("bytes must be 4 or 8")52        return None53    return x_float54def decimal_to_int(x, bytes=4):55    if bytes == 4:56        packed = struct.pack('f', x)57        (x_int,) = struct.unpack('I', packed)...Week_1_basic_Q7.py
Source:Week_1_basic_Q7.py  
1"""7. Print 123 in decimal, binary, octal and hexadecimal format using base conversion functions """2def int_to_decimal(number):3    decimal = float(number)4    print(number, " in decimal :", decimal)5def int_to_binary(number):6    binary = bin(number)7    print(number, " in binary :", binary)8def int_to_octal(number):9    octal = oct(number)10    print(number, " in octal :", octal)11def int_to_hexadecimal(number):12    hexnum = hex(number)13    print(number, " in hexadecimal :", hexnum)14num = 12315int_to_decimal(num)16int_to_binary(num)17int_to_octal(num)...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!!
