Best Python code snippet using hypothesis
challenge-1.py
Source:challenge-1.py
1"""2This is a dumb calculator that can add and subtract whole numbers from zero to five.3When you run the code, you are prompted to enter two numbers (in the form of English4word instead of number) and the operator sign (also in the form of English word).5The code will perform the calculation and give the result if your input is what it6expects.7The code is very long and messy. Refactor it according to what you have learned about8code simplicity and efficiency.9"""10print('Welcome to this calculator!')11print('It can add and subtract whole numbers from zero to five')12a = input('Please choose your first number (zero to five): ')13b = input('What do you want to do? plus or minus: ')14c = input('Please choose your second number (zero to five): ')15if a == 'zero' and b == 'plus' and c == 'zero':16 print("zero plus zero equals zero")17if a == 'zero' and b == 'plus' and c == 'one':18 print("zero plus one equals one")19if a == 'zero' and b == 'plus' and c == 'two':20 print("zero plus two equals two")21if a == 'zero' and b == 'plus' and c == 'three':22 print("zero plus three equals three")23if a == 'zero' and b == 'plus' and c == 'four':24 print("zero plus four equals four")25if a == 'zero' and b == 'plus' and c == 'five':26 print("zero plus five equals five")27if a == 'one' and b == 'plus' and c == 'zero':28 print("one plus zero equals one")29if a == 'one' and b == 'plus' and c == 'one':30 print("one plus one equals two")31if a == 'one' and b == 'plus' and c == 'two':32 print("one plus two equals three")33if a == 'one' and b == 'plus' and c == 'three':34 print("one plus three equals four")35if a == 'one' and b == 'plus' and c == 'four':36 print("one plus four equals five")37if a == 'one' and b == 'plus' and c == 'five':38 print("one plus five equals six")39if a == 'two' and b == 'plus' and c == 'zero':40 print("two plus zero equals two")41if a == 'two' and b == 'plus' and c == 'one':42 print("two plus one equals three")43if a == 'two' and b == 'plus' and c == 'two':44 print("two plus two equals four")45if a == 'two' and b == 'plus' and c == 'three':46 print("two plus three equals five")47if a == 'two' and b == 'plus' and c == 'four':48 print("two plus four equals six")49if a == 'two' and b == 'plus' and c == 'five':50 print("two plus five equals seven")51if a == 'three' and b == 'plus' and c == 'zero':52 print("three plus zero equals three")53if a == 'three' and b == 'plus' and c == 'one':54 print("three plus one equals four")55if a == 'three' and b == 'plus' and c == 'two':56 print("three plus two equals five")57if a == 'three' and b == 'plus' and c == 'three':58 print("three plus three equals six")59if a == 'three' and b == 'plus' and c == 'four':60 print("three plus four equals seven")61if a == 'three' and b == 'plus' and c == 'five':62 print("three plus five equals eight")63if a == 'four' and b == 'plus' and c == 'zero':64 print("four plus zero equals four")65if a == 'four' and b == 'plus' and c == 'one':66 print("four plus one equals five")67if a == 'four' and b == 'plus' and c == 'two':68 print("four plus two equals six")69if a == 'four' and b == 'plus' and c == 'three':70 print("four plus three equals seven")71if a == 'four' and b == 'plus' and c == 'four':72 print("four plus four equals eight")73if a == 'four' and b == 'plus' and c == 'five':74 print("four plus five equals nine")75if a == 'five' and b == 'plus' and c == 'zero':76 print("five plus zero equals five")77if a == 'five' and b == 'plus' and c == 'one':78 print("five plus one equals six")79if a == 'five' and b == 'plus' and c == 'two':80 print("five plus two equals seven")81if a == 'five' and b == 'plus' and c == 'three':82 print("five plus three equals eight")83if a == 'five' and b == 'plus' and c == 'four':84 print("five plus four equals nine")85if a == 'five' and b == 'plus' and c == 'five':86 print("five plus five equals ten")87if a == 'zero' and b == 'minus' and c == 'zero':88 print("zero minus zero equals zero")89if a == 'zero' and b == 'minus' and c == 'one':90 print("zero minus one equals negative one")91if a == 'zero' and b == 'minus' and c == 'two':92 print("zero minus two equals negative two")93if a == 'zero' and b == 'minus' and c == 'three':94 print("zero minus three equals negative three")95if a == 'zero' and b == 'minus' and c == 'four':96 print("zero minus four equals negative four")97if a == 'zero' and b == 'minus' and c == 'five':98 print("zero minus five equals negative five")99if a == 'one' and b == 'minus' and c == 'zero':100 print("one minus zero equals one")101if a == 'one' and b == 'minus' and c == 'one':102 print("one minus one equals zero")103if a == 'one' and b == 'minus' and c == 'two':104 print("one minus two equals negative one")105if a == 'one' and b == 'minus' and c == 'three':106 print("one minus three equals negative three")107if a == 'one' and b == 'minus' and c == 'four':108 print("one minus four equals negative three")109if a == 'one' and b == 'minus' and c == 'five':110 print("one minus five equals negative four")111if a == 'two' and b == 'minus' and c == 'zero':112 print("two minus zero equals two")113if a == 'two' and b == 'minus' and c == 'one':114 print("two minus one equals one")115if a == 'two' and b == 'minus' and c == 'two':116 print("two minus two equals zero")117if a == 'two' and b == 'minus' and c == 'three':118 print("two minus three equals negative one")119if a == 'two' and b == 'minus' and c == 'four':120 print("two minus four equals negative two")121if a == 'two' and b == 'minus' and c == 'five':122 print("two minus five equals negative three")123if a == 'three' and b == 'minus' and c == 'zero':124 print("three minus zero equals three")125if a == 'three' and b == 'minus' and c == 'one':126 print("three minus one equals two")127if a == 'three' and b == 'minus' and c == 'two':128 print("three minus two equals one")129if a == 'three' and b == 'minus' and c == 'three':130 print("three minus three equals zero")131if a == 'three' and b == 'minus' and c == 'four':132 print("three minus four equals negative one")133if a == 'three' and b == 'minus' and c == 'five':134 print("three minus five equals negative two")135if a == 'four' and b == 'minus' and c == 'zero':136 print("four minus zero equals four")137if a == 'four' and b == 'minus' and c == 'one':138 print("four minus one equals three")139if a == 'four' and b == 'minus' and c == 'two':140 print("four minus two equals two")141if a == 'four' and b == 'minus' and c == 'three':142 print("four minus three equals one")143if a == 'four' and b == 'minus' and c == 'four':144 print("four minus four equals zero")145if a == 'four' and b == 'minus' and c == 'five':146 print("four minus five equals negative one")147if a == 'five' and b == 'minus' and c == 'zero':148 print("five minus zero equals five")149if a == 'five' and b == 'minus' and c == 'one':150 print("five minus one equals four")151if a == 'five' and b == 'minus' and c == 'two':152 print("five minus two equals three")153if a == 'five' and b == 'minus' and c == 'three':154 print("five minus three equals two")155if a == 'five' and b == 'minus' and c == 'four':156 print("five minus four equals one")157if a == 'five' and b == 'minus' and c == 'five':158 print("five minus five equals zero")159if (not a == 'zero' and not a == 'one' and not a == 'two' and not a == 'three' and not a == 'four' and not a == 'five') or (not c == 'zero' and not c == 'one' and not c == 'two' and not c == 'three' and not c == 'four' and not c == 'five') or (not b == 'plus' and not b == 'minus'):160 print("I am not able to answer this question. Check your input.")...
BUILD
Source:BUILD
1# Description:2# Code examples referenced by adding_an_op3package(4 default_visibility = ["//tensorflow:internal"],5 features = [6 "-layering_check",7 "-parse_headers",8 ],9)10licenses(["notice"]) # Apache 2.011load("//tensorflow:tensorflow.bzl", "tf_custom_op_library")12load("//tensorflow:tensorflow.bzl", "tf_cuda_tests_tags")13exports_files(["LICENSE"])14tf_custom_op_library(15 name = "zero_out_op_kernel_1.so",16 srcs = ["zero_out_op_kernel_1.cc"],17)18py_library(19 name = "zero_out_op_1",20 srcs = ["zero_out_op_1.py"],21 data = [":zero_out_op_kernel_1.so"],22 srcs_version = "PY2AND3",23)24tf_custom_op_library(25 name = "zero_out_op_kernel_2.so",26 srcs = ["zero_out_op_kernel_2.cc"],27)28py_library(29 name = "zero_out_op_2",30 srcs = ["zero_out_op_2.py"],31 data = [":zero_out_op_kernel_2.so"],32 srcs_version = "PY2AND3",33)34tf_custom_op_library(35 name = "zero_out_op_kernel_3.so",36 srcs = ["zero_out_op_kernel_3.cc"],37)38py_library(39 name = "zero_out_op_3",40 srcs = ["zero_out_op_3.py"],41 data = [":zero_out_op_kernel_3.so"],42 srcs_version = "PY2AND3",43)44py_library(45 name = "zero_out_grad_2",46 srcs = ["zero_out_grad_2.py"],47 srcs_version = "PY2AND3",48 deps = [49 ":zero_out_op_2",50 "//tensorflow:tensorflow_py",51 ],52)53py_test(54 name = "zero_out_1_test",55 size = "small",56 srcs = ["zero_out_1_test.py"],57 srcs_version = "PY2AND3",58 deps = [59 ":zero_out_op_1",60 "//tensorflow:tensorflow_py",61 ],62)63py_test(64 name = "zero_out_2_test",65 size = "small",66 srcs = ["zero_out_2_test.py"],67 srcs_version = "PY2AND3",68 deps = [69 ":zero_out_grad_2",70 ":zero_out_op_2",71 "//tensorflow:tensorflow_py",72 ],73)74py_test(75 name = "zero_out_3_test",76 size = "small",77 srcs = ["zero_out_3_test.py"],78 srcs_version = "PY2AND3",79 deps = [80 ":zero_out_op_3",81 "//tensorflow:tensorflow_py",82 ],83)84tf_custom_op_library(85 name = "cuda_op_kernel.so",86 srcs = ["cuda_op_kernel.cc"],87 gpu_srcs = ["cuda_op_kernel.cu.cc"],88)89py_library(90 name = "cuda_op",91 srcs = ["cuda_op.py"],92 data = [":cuda_op_kernel.so"],93 srcs_version = "PY2AND3",94)95py_test(96 name = "cuda_op_test",97 size = "small",98 srcs = ["cuda_op_test.py"],99 srcs_version = "PY2AND3",100 tags = tf_cuda_tests_tags(),101 deps = [102 ":cuda_op",103 "//tensorflow:tensorflow_py",104 ],105)106py_test(107 name = "fact_test",108 size = "small",109 srcs = ["fact_test.py"],110 srcs_version = "PY2AND3",111 deps = [112 "//tensorflow:tensorflow_py",113 ],114)115cc_binary(116 name = "attr_examples",117 srcs = ["attr_examples.cc"],118 deps = [119 "//tensorflow/core",120 ],121)122filegroup(123 name = "all_files",124 srcs = glob(125 ["**/*"],126 exclude = [127 "**/METADATA",128 "**/OWNERS",129 ],130 ),131 visibility = ["//tensorflow:__subpackages__"],...
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!!