Best Python code snippet using elementium_python
lab4-test.py
Source: lab4-test.py
1import math2import numpy as np3import matplotlib.pyplot as plt4def myFun(x)->float:5 return (math.e**((-2)*x))+(x**2)-16def myFunPrime(x)->float:7 return (2*x - 2*math.e**((-2)*x))8def myFunBis(x)->float:9 return (4*math.e**(-2*x)+2)10 11def bisekcja(a: float, b: float, Ex: float)->float:12 plt.axhline(y = 0, color = 'm')13 x1 = (a+b)/214 plt.plot([a, b, x1], [0, 0, 0], 'bs')15 if math.fabs(myFun(x1)) <= Ex:16 return x117 elif myFun(x1)*myFun(a) < 0:18 b = x119 else:20 a = x121 22 x1 = (a+b)/223 plt.plot([a, b, x1], [0.2, 0.2, 0.2], 'g^')24 if math.fabs(myFun(x1)) <= Ex:25 return x126 elif myFun(x1)*myFun(a) < 0:27 b = x128 else:29 a = x130 x1 = (a+b)/231 plt.plot([a, b, x1], [0.4, 0.4, 0.4], 'ro')32 33 y =[]34 x = np.linspace(-1, 1.0, 300)35 for i in x:36 y.append(myFun(i))37 plt.plot(x, y)38 plt.show()39def siecznych(x0, x1, n, Ex):40 41 y = []42 x = np.linspace(-5, 5, 300)43 for i in x:44 y.append(myFun(i))45 plt.plot(x, y)46 plt.plot([x0, x1], [0, 0], 'bs')47 plt.plot([x0, x1], [myFun(x0), myFun(x1)], 'b')48 plt.axhline(y = 0, color = 'm')49 plt.axis([-2, 1, -1, 8])50 51 if math.fabs(myFun(x1) - myFun(x0)) <= Ex:52 return x153 x_temp = x1 - (myFun(x1)*(x1-x0)*1.0)/(myFun(x1) - myFun(x0))54 plt.plot([x_temp], [0], 'bs')55 x0 = x156 x1 = x_temp57 plt.plot([x0, x1], [myFun(x0), myFun(x1)], 'r')58 59 if math.fabs(myFun(x1) - myFun(x0)) <= Ex:60 return x161 x_temp = x1 - (myFun(x1)*(x1-x0)*1.0)/(myFun(x1) - myFun(x0))62 x0 = x163 x1 = x_temp64 plt.plot([x0, x1], [myFun(x0), myFun(x1)], 'g')65 plt.plot([x_temp], [0], 'g^')66def stycznychNewtona(x0, E0, Ex):67 y = myFun(x0)68 yp = myFunPrime(x0)69 if abs(yp) < Ex:70 return None71 x1 = x0 - y/yp72 if abs(x0 - x1) <= E0:73 return x174 x0 = x175 stycznychNewtona(x0, E0, Ex)76bisekcja(-1, 0.5, 1.0e-6)77siecznych(-1, 0.4, 200, 1.0e-6)...
args_kwargs.py
Source: args_kwargs.py
1## *args23def myFun(*argv):4 for arg in argv:5 print(arg)67myFun('Hello', 'Welcome', 'to', 'GeeksforGeeks')89def myFun(arg1, *argv):10 print(arg1)11 for arg in argv:12 print(arg)1314myFun('Hello', 'Welcome', 'to', 'GeeksforGeeks')1516## **kwargs1718def myFun(**kwargs):19 for key, value in kwargs.items():20 print("%s == %s", %(key, value))2122myFun(first ='Geeks', mid ='for', last='Geeks') 2324def myFun(arg1, **kwargs):25 for key, value in kwargs.items():26 print("%s == %s" %(key, value))2728myFun("Hi", first ='Geeks', mid ='for', last='Geeks')2930## Using *args and **kwargs to call a function31def myFun(arg1, arg2, arg3):32 print("arg1:", arg1)33 print("arg2:", arg2)34 print("arg3:", arg3)3536args = ("Geeks", "for", "Geeks")37myFun(*args)3839kwargs = {"arg1" : "Geeks", "arg2" : "for", "arg3" : "Geeks"}40myFun(**kwargs)4142## Using *args and **kwargs in same line to call a function4344def myFun(*args, **kwargs):45 print("args: ", args)46 print("kwargs: ", kwargs)4748myFun('geeks','for','geeks',first="Geeks",mid="for",last="Geeks")495051
...
python-9_1.py
Source: python-9_1.py
1Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win322Type "help", "copyright", "credits" or "license()" for more information.3>>> def myfun(x,y):4 return x*y56>>> myfun(3,4)7128>>> def myfun(x):9 return x*31011>>> def apply(q,x):12 return q(x)1314>>> apply(myfun, 7)152116>>> def myfun(b, c=3, d="hello"):17 return b+c1819>>> myfun(5,3,"hello")20821>>> myfun(5,3)22823>>> myfun(5)24825>>> def myfun(a,b,c):26 return a-b2728>>> myfun(2,1,43)29130>>> myfun(c=43,b=1,a=2)31132>>> myfun(2,c=43,b=1)331
...
Check out the latest blogs from LambdaTest on this topic:
Most test automation tools just do test execution automation. Without test design involved in the whole test automation process, the test cases remain ad hoc and detect only simple bugs. This solution is just automation without real testing. In addition, test execution automation is very inefficient.
Software Risk Management (SRM) combines a set of tools, processes, and methods for managing risks in the software development lifecycle. In SRM, we want to make informed decisions about what can go wrong at various levels within a company (e.g., business, project, and software related).
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
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!!