content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# This file was generated by the "capture_real_responses.py" script. # On Wed, 20 Nov 2019 19:34:18 +0000. # # To update it run: # python -m tests.providers.capture_real_responses captured_responses = [ { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>01001000</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "success", "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro>S\xe9</bairro><cep>01001000</cep><cidade>S\xe3o Paulo</cidade><complemento2>- lado \xedmpar</complemento2><end>Pra\xe7a da S\xe9</end><uf>SP</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=01001000&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"resultado":"1","resultado_txt":"sucesso - cep completo","uf":"SP","cidade":"S\\u00e3o Paulo","bairro":"S\\u00e9","tipo_logradouro":"Pra\\u00e7a","logradouro":"da S\\u00e9"}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/01001000/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": { "type": "success", "data": b'{\n "cep": "01001-000",\n "logradouro": "Pra\\u00e7a da S\\u00e9",\n "complemento": "lado \\u00edmpar",\n "bairro": "S\\u00e9",\n "localidade": "S\\u00e3o Paulo",\n "uf": "SP",\n "unidade": "",\n "ibge": "3550308",\n "gia": "1004"\n}', }, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>57010240</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "success", "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro>Prado</bairro><cep>57010240</cep><cidade>Macei\xf3</cidade><complemento2></complemento2><end>Rua Desembargador Inoc\xeancio Lins</end><uf>AL</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=57010240&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"resultado":"1","resultado_txt":"sucesso - cep completo","uf":"AL","cidade":"Macei\\u00f3","bairro":"Prado","tipo_logradouro":"Rua","logradouro":"Desembargador Inoc\\u00eancio Lins"}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/57010240/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": { "type": "success", "data": b'{\n "cep": "57010-240",\n "logradouro": "Rua Desembargador Inoc\\u00eancio Lins",\n "complemento": "",\n "bairro": "Prado",\n "localidade": "Macei\\u00f3",\n "uf": "AL",\n "unidade": "",\n "ibge": "2704302",\n "gia": ""\n}', }, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>18170000</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "success", "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro></bairro><cep>18170000</cep><cidade>Piedade</cidade><complemento2></complemento2><end></end><uf>SP</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=18170000&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"resultado":"2","resultado_txt":"sucesso - cep \\u00fanico","uf":"SP","cidade":"Piedade","bairro":"","tipo_logradouro":"","logradouro":"","debug":" - encontrado via search_db cep unico - "}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/18170000/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": { "type": "success", "data": b'{\n "cep": "18170-000",\n "logradouro": "",\n "complemento": "",\n "bairro": "",\n "localidade": "Piedade",\n "uf": "SP",\n "unidade": "",\n "ibge": "3537800",\n "gia": "5265"\n}', }, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>78175000</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "success", "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro></bairro><cep>78175000</cep><cidade>Pocon\xe9</cidade><complemento2></complemento2><end></end><uf>MT</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=78175000&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"resultado":"2","resultado_txt":"sucesso - cep \\u00fanico","uf":"MT","cidade":"Pocon\\u00e9","bairro":"","tipo_logradouro":"","logradouro":"","debug":" - encontrado via search_db cep unico - "}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/78175000/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": { "type": "success", "data": b'{\n "cep": "78175-000",\n "logradouro": "",\n "complemento": "",\n "bairro": "",\n "localidade": "Pocon\\u00e9",\n "uf": "MT",\n "unidade": "",\n "ibge": "5106505",\n "gia": ""\n}', }, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>63200970</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "success", "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro>Centro</bairro><cep>63200970</cep><cidade>Miss\xe3o Velha</cidade><complemento2></complemento2><end>Rua Jos\xe9 Sobreira da Cruz 271</end><uf>CE</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=63200970&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"1","resultado_txt":"sucesso - cep completo","uf":"CE","cidade":"Miss\\u00e3o Velha","bairro":"Centro\\u00a0","tipo_logradouro":"Rua","logradouro":"Jos\\u00e9 Sobreira da Cruz, 271 "}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/63200970/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": { "type": "success", "data": b'{\n "cep": "63200-970",\n "logradouro": "Rua Jos\\u00e9 Sobreira da Cruz 271",\n "complemento": "",\n "bairro": "Centro",\n "localidade": "Miss\\u00e3o Velha",\n "uf": "CE",\n "unidade": "",\n "ibge": "2308401",\n "gia": ""\n}', }, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>69096970</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "success", "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro>Cidade Nova</bairro><cep>69096970</cep><cidade>Manaus</cidade><complemento2></complemento2><end>Avenida Noel Nutels 1350</end><uf>AM</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=69096970&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"1","resultado_txt":"sucesso - cep completo","uf":"AM","cidade":"Manaus","bairro":"Cidade Nova\\u00a0","tipo_logradouro":"Avenida","logradouro":"Noel Nutels, 1350 "}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/69096970/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": { "type": "success", "data": b'{\n "cep": "69096-970",\n "logradouro": "Avenida Noel Nutels 1350",\n "complemento": "",\n "bairro": "Cidade Nova",\n "localidade": "Manaus",\n "uf": "AM",\n "unidade": "",\n "ibge": "1302603",\n "gia": ""\n}', }, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>20010974</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "success", "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro>Centro</bairro><cep>20010974</cep><cidade>Rio de Janeiro</cidade><complemento2></complemento2><end>Rua Primeiro de Mar\xe7o 64</end><uf>RJ</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=20010974&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"1","resultado_txt":"sucesso - cep completo","uf":"RJ","cidade":"Rio de Janeiro","bairro":"Centro\\u00a0","tipo_logradouro":"Rua","logradouro":"Primeiro de Mar\\u00e7o, 64 "}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/20010974/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": { "type": "success", "data": b'{\n "cep": "20010-974",\n "logradouro": "Rua Primeiro de Mar\\u00e7o",\n "complemento": "64",\n "bairro": "Centro",\n "localidade": "Rio de Janeiro",\n "uf": "RJ",\n "unidade": "",\n "ibge": "3304557",\n "gia": ""\n}', }, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>96010900</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "success", "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro>Centro</bairro><cep>96010900</cep><cidade>Pelotas</cidade><complemento2></complemento2><end>Rua Tiradentes 2515</end><uf>RS</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=96010900&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"1","resultado_txt":"sucesso - cep completo","uf":"RS","cidade":"Pelotas","bairro":"Centro\\u00a0","tipo_logradouro":"Rua","logradouro":"Tiradentes, 2515 "}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/96010900/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": { "type": "success", "data": b'{\n "cep": "96010-900",\n "logradouro": "Rua Tiradentes",\n "complemento": "2515",\n "bairro": "Centro",\n "localidade": "Pelotas",\n "uf": "RS",\n "unidade": "",\n "ibge": "4314407",\n "gia": ""\n}', }, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>38101990</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "success", "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro></bairro><cep>38101990</cep><cidade>Baixa (Uberaba)</cidade><complemento2></complemento2><end>Rua Bas\xedlio Eug\xeanio dos Santos</end><uf>MG</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=38101990&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"1","resultado_txt":"sucesso - cep completo","uf":"MG - Distrito","cidade":"Baixa (Uberaba)","bairro":"\\u00a0","tipo_logradouro":"Rua","logradouro":"Bas\\u00edlio Eug\\u00eanio dos Santos "}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/38101990/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": { "type": "success", "data": b'{\n "cep": "38101-990",\n "logradouro": "Rua Bas\\u00edlio Eug\\u00eanio dos Santos",\n "complemento": "",\n "bairro": "Baixa",\n "localidade": "Uberaba",\n "uf": "MG",\n "unidade": "",\n "ibge": "3170107",\n "gia": ""\n}', }, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>76840000</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "success", "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro></bairro><cep>76840000</cep><cidade>Jaci Paran\xe1 (Porto Velho)</cidade><complemento2></complemento2><end></end><uf>RO</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=76840000&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"2","resultado_txt":"sucesso - cep \\u00fanico","uf":"RO - Distrito","cidade":"Jaci Paran\\u00e1 (Porto Velho)","bairro":"\\u00a0","tipo_logradouro":"","logradouro":""}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/76840000/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": { "type": "success", "data": b'{\n "cep": "76840-000",\n "logradouro": "",\n "complemento": "",\n "bairro": "",\n "localidade": "Jaci Paran\\u00e1 (Porto Velho)",\n "uf": "RO",\n "unidade": "",\n "ibge": "1100205",\n "gia": ""\n}', }, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>86055991</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "success", "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro></bairro><cep>86055991</cep><cidade>Londrina</cidade><complemento2></complemento2><end>Rodovia M\xe1bio Gon\xe7alves Palhano, s/n</end><uf>PR</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=86055991&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"1","resultado_txt":"sucesso - cep completo","uf":"PR","cidade":"Londrina","bairro":"\\u00a0","tipo_logradouro":"Rodovia","logradouro":"M\\u00e1bio Gon\\u00e7alves Palhano, s\\/n "}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/86055991/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": { "type": "success", "data": b'{\n "cep": "86055-991",\n "logradouro": "Rodovia M\\u00e1bio Gon\\u00e7alves Palhano",\n "complemento": "s/n",\n "bairro": "",\n "localidade": "Londrina",\n "uf": "PR",\n "unidade": "",\n "ibge": "4113700",\n "gia": ""\n}', }, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>00000000</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "error", "status": 500, "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>CEP INV\xc1LIDO</faultstring><detail><ns2:SigepClienteException xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">CEP INV\xc1LIDO</ns2:SigepClienteException></detail></soap:Fault></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=00000000&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"0","resultado_txt":"sucesso - cep n\\u00e3o encontrado","uf":"","cidade":"","bairro":"","tipo_logradouro":"","logradouro":""}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/00000000/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": {"type": "success", "data": b'{\n "erro": true\n}'}, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>11111111</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "error", "status": 500, "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>CEP INV\xc1LIDO</faultstring><detail><ns2:SigepClienteException xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">CEP INV\xc1LIDO</ns2:SigepClienteException></detail></soap:Fault></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=11111111&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"0","resultado_txt":"sucesso - cep n\\u00e3o encontrado","uf":"","cidade":"","bairro":"","tipo_logradouro":"","logradouro":""}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/11111111/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": {"type": "success", "data": b'{\n "erro": true\n}'}, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>99999999</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "error", "status": 500, "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>CEP INV\xc1LIDO</faultstring><detail><ns2:SigepClienteException xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">CEP INV\xc1LIDO</ns2:SigepClienteException></detail></soap:Fault></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=99999999&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"0","resultado_txt":"sucesso - cep n\\u00e3o encontrado","uf":"","cidade":"","bairro":"","tipo_logradouro":"","logradouro":""}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/99999999/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": {"type": "success", "data": b'{\n "erro": true\n}'}, }, { "request": { "full_url": "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente", "method": "POST", "headers": {}, "data": bytearray( b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>01111110</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>' ), }, "response": { "type": "success", "data": b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"/></soap:Body></soap:Envelope>', }, }, { "request": { "full_url": "http://cep.republicavirtual.com.br/web_cep.php?cep=01111110&formato=json", "method": "GET", "headers": {"Accept": "application/json"}, "data": None, }, "response": { "type": "success", "data": b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"0","resultado_txt":"sucesso - cep n\\u00e3o encontrado","uf":"","cidade":"","bairro":"","tipo_logradouro":"","logradouro":""}', }, }, { "request": { "full_url": "https://viacep.com.br/ws/01111110/json/unicode/", "method": "GET", "headers": {}, "data": None, }, "response": {"type": "success", "data": b'{\n "erro": true\n}'}, }, ]
captured_responses = [{'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>01001000</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'success', 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro>S\xe9</bairro><cep>01001000</cep><cidade>S\xe3o Paulo</cidade><complemento2>- lado \xedmpar</complemento2><end>Pra\xe7a da S\xe9</end><uf>SP</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=01001000&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"resultado":"1","resultado_txt":"sucesso - cep completo","uf":"SP","cidade":"S\\u00e3o Paulo","bairro":"S\\u00e9","tipo_logradouro":"Pra\\u00e7a","logradouro":"da S\\u00e9"}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/01001000/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "cep": "01001-000",\n "logradouro": "Pra\\u00e7a da S\\u00e9",\n "complemento": "lado \\u00edmpar",\n "bairro": "S\\u00e9",\n "localidade": "S\\u00e3o Paulo",\n "uf": "SP",\n "unidade": "",\n "ibge": "3550308",\n "gia": "1004"\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>57010240</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'success', 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro>Prado</bairro><cep>57010240</cep><cidade>Macei\xf3</cidade><complemento2></complemento2><end>Rua Desembargador Inoc\xeancio Lins</end><uf>AL</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=57010240&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"resultado":"1","resultado_txt":"sucesso - cep completo","uf":"AL","cidade":"Macei\\u00f3","bairro":"Prado","tipo_logradouro":"Rua","logradouro":"Desembargador Inoc\\u00eancio Lins"}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/57010240/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "cep": "57010-240",\n "logradouro": "Rua Desembargador Inoc\\u00eancio Lins",\n "complemento": "",\n "bairro": "Prado",\n "localidade": "Macei\\u00f3",\n "uf": "AL",\n "unidade": "",\n "ibge": "2704302",\n "gia": ""\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>18170000</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'success', 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro></bairro><cep>18170000</cep><cidade>Piedade</cidade><complemento2></complemento2><end></end><uf>SP</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=18170000&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"resultado":"2","resultado_txt":"sucesso - cep \\u00fanico","uf":"SP","cidade":"Piedade","bairro":"","tipo_logradouro":"","logradouro":"","debug":" - encontrado via search_db cep unico - "}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/18170000/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "cep": "18170-000",\n "logradouro": "",\n "complemento": "",\n "bairro": "",\n "localidade": "Piedade",\n "uf": "SP",\n "unidade": "",\n "ibge": "3537800",\n "gia": "5265"\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>78175000</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'success', 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro></bairro><cep>78175000</cep><cidade>Pocon\xe9</cidade><complemento2></complemento2><end></end><uf>MT</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=78175000&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"resultado":"2","resultado_txt":"sucesso - cep \\u00fanico","uf":"MT","cidade":"Pocon\\u00e9","bairro":"","tipo_logradouro":"","logradouro":"","debug":" - encontrado via search_db cep unico - "}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/78175000/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "cep": "78175-000",\n "logradouro": "",\n "complemento": "",\n "bairro": "",\n "localidade": "Pocon\\u00e9",\n "uf": "MT",\n "unidade": "",\n "ibge": "5106505",\n "gia": ""\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>63200970</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'success', 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro>Centro</bairro><cep>63200970</cep><cidade>Miss\xe3o Velha</cidade><complemento2></complemento2><end>Rua Jos\xe9 Sobreira da Cruz 271</end><uf>CE</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=63200970&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"1","resultado_txt":"sucesso - cep completo","uf":"CE","cidade":"Miss\\u00e3o Velha","bairro":"Centro\\u00a0","tipo_logradouro":"Rua","logradouro":"Jos\\u00e9 Sobreira da Cruz, 271 "}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/63200970/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "cep": "63200-970",\n "logradouro": "Rua Jos\\u00e9 Sobreira da Cruz 271",\n "complemento": "",\n "bairro": "Centro",\n "localidade": "Miss\\u00e3o Velha",\n "uf": "CE",\n "unidade": "",\n "ibge": "2308401",\n "gia": ""\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>69096970</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'success', 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro>Cidade Nova</bairro><cep>69096970</cep><cidade>Manaus</cidade><complemento2></complemento2><end>Avenida Noel Nutels 1350</end><uf>AM</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=69096970&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"1","resultado_txt":"sucesso - cep completo","uf":"AM","cidade":"Manaus","bairro":"Cidade Nova\\u00a0","tipo_logradouro":"Avenida","logradouro":"Noel Nutels, 1350 "}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/69096970/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "cep": "69096-970",\n "logradouro": "Avenida Noel Nutels 1350",\n "complemento": "",\n "bairro": "Cidade Nova",\n "localidade": "Manaus",\n "uf": "AM",\n "unidade": "",\n "ibge": "1302603",\n "gia": ""\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>20010974</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'success', 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro>Centro</bairro><cep>20010974</cep><cidade>Rio de Janeiro</cidade><complemento2></complemento2><end>Rua Primeiro de Mar\xe7o 64</end><uf>RJ</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=20010974&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"1","resultado_txt":"sucesso - cep completo","uf":"RJ","cidade":"Rio de Janeiro","bairro":"Centro\\u00a0","tipo_logradouro":"Rua","logradouro":"Primeiro de Mar\\u00e7o, 64 "}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/20010974/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "cep": "20010-974",\n "logradouro": "Rua Primeiro de Mar\\u00e7o",\n "complemento": "64",\n "bairro": "Centro",\n "localidade": "Rio de Janeiro",\n "uf": "RJ",\n "unidade": "",\n "ibge": "3304557",\n "gia": ""\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>96010900</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'success', 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro>Centro</bairro><cep>96010900</cep><cidade>Pelotas</cidade><complemento2></complemento2><end>Rua Tiradentes 2515</end><uf>RS</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=96010900&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"1","resultado_txt":"sucesso - cep completo","uf":"RS","cidade":"Pelotas","bairro":"Centro\\u00a0","tipo_logradouro":"Rua","logradouro":"Tiradentes, 2515 "}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/96010900/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "cep": "96010-900",\n "logradouro": "Rua Tiradentes",\n "complemento": "2515",\n "bairro": "Centro",\n "localidade": "Pelotas",\n "uf": "RS",\n "unidade": "",\n "ibge": "4314407",\n "gia": ""\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>38101990</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'success', 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro></bairro><cep>38101990</cep><cidade>Baixa (Uberaba)</cidade><complemento2></complemento2><end>Rua Bas\xedlio Eug\xeanio dos Santos</end><uf>MG</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=38101990&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"1","resultado_txt":"sucesso - cep completo","uf":"MG - Distrito","cidade":"Baixa (Uberaba)","bairro":"\\u00a0","tipo_logradouro":"Rua","logradouro":"Bas\\u00edlio Eug\\u00eanio dos Santos "}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/38101990/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "cep": "38101-990",\n "logradouro": "Rua Bas\\u00edlio Eug\\u00eanio dos Santos",\n "complemento": "",\n "bairro": "Baixa",\n "localidade": "Uberaba",\n "uf": "MG",\n "unidade": "",\n "ibge": "3170107",\n "gia": ""\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>76840000</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'success', 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro></bairro><cep>76840000</cep><cidade>Jaci Paran\xe1 (Porto Velho)</cidade><complemento2></complemento2><end></end><uf>RO</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=76840000&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"2","resultado_txt":"sucesso - cep \\u00fanico","uf":"RO - Distrito","cidade":"Jaci Paran\\u00e1 (Porto Velho)","bairro":"\\u00a0","tipo_logradouro":"","logradouro":""}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/76840000/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "cep": "76840-000",\n "logradouro": "",\n "complemento": "",\n "bairro": "",\n "localidade": "Jaci Paran\\u00e1 (Porto Velho)",\n "uf": "RO",\n "unidade": "",\n "ibge": "1100205",\n "gia": ""\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>86055991</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'success', 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"><return><bairro></bairro><cep>86055991</cep><cidade>Londrina</cidade><complemento2></complemento2><end>Rodovia M\xe1bio Gon\xe7alves Palhano, s/n</end><uf>PR</uf></return></ns2:consultaCEPResponse></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=86055991&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"1","resultado_txt":"sucesso - cep completo","uf":"PR","cidade":"Londrina","bairro":"\\u00a0","tipo_logradouro":"Rodovia","logradouro":"M\\u00e1bio Gon\\u00e7alves Palhano, s\\/n "}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/86055991/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "cep": "86055-991",\n "logradouro": "Rodovia M\\u00e1bio Gon\\u00e7alves Palhano",\n "complemento": "s/n",\n "bairro": "",\n "localidade": "Londrina",\n "uf": "PR",\n "unidade": "",\n "ibge": "4113700",\n "gia": ""\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>00000000</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'error', 'status': 500, 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>CEP INV\xc1LIDO</faultstring><detail><ns2:SigepClienteException xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">CEP INV\xc1LIDO</ns2:SigepClienteException></detail></soap:Fault></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=00000000&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"0","resultado_txt":"sucesso - cep n\\u00e3o encontrado","uf":"","cidade":"","bairro":"","tipo_logradouro":"","logradouro":""}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/00000000/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "erro": true\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>11111111</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'error', 'status': 500, 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>CEP INV\xc1LIDO</faultstring><detail><ns2:SigepClienteException xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">CEP INV\xc1LIDO</ns2:SigepClienteException></detail></soap:Fault></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=11111111&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"0","resultado_txt":"sucesso - cep n\\u00e3o encontrado","uf":"","cidade":"","bairro":"","tipo_logradouro":"","logradouro":""}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/11111111/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "erro": true\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>99999999</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'error', 'status': 500, 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>CEP INV\xc1LIDO</faultstring><detail><ns2:SigepClienteException xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/">CEP INV\xc1LIDO</ns2:SigepClienteException></detail></soap:Fault></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=99999999&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"0","resultado_txt":"sucesso - cep n\\u00e3o encontrado","uf":"","cidade":"","bairro":"","tipo_logradouro":"","logradouro":""}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/99999999/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "erro": true\n}'}}, {'request': {'full_url': 'https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente', 'method': 'POST', 'headers': {}, 'data': bytearray(b'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/">\n <soapenv:Header/>\n <soapenv:Body>\n <cli:consultaCEP>\n <cep>01111110</cep>\n </cli:consultaCEP>\n </soapenv:Body>\n </soapenv:Envelope>')}, 'response': {'type': 'success', 'data': b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:consultaCEPResponse xmlns:ns2="http://cliente.bean.master.sigep.bsb.correios.com.br/"/></soap:Body></soap:Envelope>'}}, {'request': {'full_url': 'http://cep.republicavirtual.com.br/web_cep.php?cep=01111110&formato=json', 'method': 'GET', 'headers': {'Accept': 'application/json'}, 'data': None}, 'response': {'type': 'success', 'data': b'{"debug":" - nao encontrado via search_db cep unico - ","resultado":"0","resultado_txt":"sucesso - cep n\\u00e3o encontrado","uf":"","cidade":"","bairro":"","tipo_logradouro":"","logradouro":""}'}}, {'request': {'full_url': 'https://viacep.com.br/ws/01111110/json/unicode/', 'method': 'GET', 'headers': {}, 'data': None}, 'response': {'type': 'success', 'data': b'{\n "erro": true\n}'}}]
def check(params): "Check input parameters" attrs = [] for attr in attrs: if attr not in params: raise Exception('key {} not in {}'.format(attr, json.dumps(params))) def execute(cur, stmt, bindings, verbose=None): "Helper function to execute statement" if verbose: print(stmt) print(bindings) cur.execute(stmt, bindings) rows = cur.fetchall() for row in rows: return row[0]
def check(params): """Check input parameters""" attrs = [] for attr in attrs: if attr not in params: raise exception('key {} not in {}'.format(attr, json.dumps(params))) def execute(cur, stmt, bindings, verbose=None): """Helper function to execute statement""" if verbose: print(stmt) print(bindings) cur.execute(stmt, bindings) rows = cur.fetchall() for row in rows: return row[0]
class Solution: def twoSum(self, numbers: List[int], target: int) -> List[int]: left, right = 0, len(numbers) - 1 while left < right: curSum = numbers[left] + numbers[right] if curSum == target: return[left + 1, right + 1] if curSum > target: right -= 1 else: left += 1 return []
class Solution: def two_sum(self, numbers: List[int], target: int) -> List[int]: (left, right) = (0, len(numbers) - 1) while left < right: cur_sum = numbers[left] + numbers[right] if curSum == target: return [left + 1, right + 1] if curSum > target: right -= 1 else: left += 1 return []
''' A collection of optional backends. You must manually select and install the backend you want. If the backend is not installed, then trying to import the module for that backend will cause an :class:`ImportError`. See :ref:`Choose a hashing backend` for more. ''' SUPPORTED_BACKENDS = [ 'pycryptodomex', # prefer this over pysha3, for pypy3 support 'pysha3', ]
""" A collection of optional backends. You must manually select and install the backend you want. If the backend is not installed, then trying to import the module for that backend will cause an :class:`ImportError`. See :ref:`Choose a hashing backend` for more. """ supported_backends = ['pycryptodomex', 'pysha3']
class BSTIterator: def __init__(self, root: Optional[TreeNode]): self.stack = [] self.pushLeftsUntilNull_(root) def next(self) -> int: root = self.stack.pop() self.pushLeftsUntilNull_(root.right) return root.val def hasNext(self) -> bool: return self.stack def pushLeftsUntilNull_(self, root: Optional[TreeNode]) -> None: while root: self.stack.append(root) root = root.left
class Bstiterator: def __init__(self, root: Optional[TreeNode]): self.stack = [] self.pushLeftsUntilNull_(root) def next(self) -> int: root = self.stack.pop() self.pushLeftsUntilNull_(root.right) return root.val def has_next(self) -> bool: return self.stack def push_lefts_until_null_(self, root: Optional[TreeNode]) -> None: while root: self.stack.append(root) root = root.left
class Cache: def __init__(self, function, limit=1000): self.function = function self.limit = limit self.purge() def get(self, key): value = self.store.get(key) if value is None: value = self.function(key) self.set(key, value) return value def set(self, key, value): if self.size < self.limit: self.size += 1 self.store[key] = value return value def purge(self): self.size = 0 self.store = dict() def __call__(self, key): return self.get(key)
class Cache: def __init__(self, function, limit=1000): self.function = function self.limit = limit self.purge() def get(self, key): value = self.store.get(key) if value is None: value = self.function(key) self.set(key, value) return value def set(self, key, value): if self.size < self.limit: self.size += 1 self.store[key] = value return value def purge(self): self.size = 0 self.store = dict() def __call__(self, key): return self.get(key)
'''10. Write a Python program to use double quotes to display strings.''' def double_quote_string(string): ans = f"\"{string}\"" return ans print(double_quote_string('This is working already'))
"""10. Write a Python program to use double quotes to display strings.""" def double_quote_string(string): ans = f'"{string}"' return ans print(double_quote_string('This is working already'))
# URI Online Judge 1176 N = 62 n1 = 0 n2 = 1 string = '0 1' for i in range(N-2): new = n1 + n2 string += (' ') + str(new) n1 = n2 n2 = new fib = [int(item) for item in string.split()] T = -1 while (T<0) or (T>60): T = int(input()) for t in range(T): entrada = int(input()) print('Fib({}) = {}'.format(entrada, fib[entrada]))
n = 62 n1 = 0 n2 = 1 string = '0 1' for i in range(N - 2): new = n1 + n2 string += ' ' + str(new) n1 = n2 n2 = new fib = [int(item) for item in string.split()] t = -1 while T < 0 or T > 60: t = int(input()) for t in range(T): entrada = int(input()) print('Fib({}) = {}'.format(entrada, fib[entrada]))
class Solution: def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]: res = ListNode(None) output = res while list1 and list2: if list1.val <= list2.val: output.next = list1 list1 = list1.next else: output.next = list2 list2 = list2.next output = output.next if list1 == None: output.next = list2 elif list2 == None: output.next = list1 return res.next
class Solution: def merge_two_lists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]: res = list_node(None) output = res while list1 and list2: if list1.val <= list2.val: output.next = list1 list1 = list1.next else: output.next = list2 list2 = list2.next output = output.next if list1 == None: output.next = list2 elif list2 == None: output.next = list1 return res.next
line = input().split('\\') line_length = len(line) -1 splitted = line[line_length].split('.') file_name = splitted[0] ext = splitted[1] print(f'File name: {file_name}') print(f'File extension: {ext}')
line = input().split('\\') line_length = len(line) - 1 splitted = line[line_length].split('.') file_name = splitted[0] ext = splitted[1] print(f'File name: {file_name}') print(f'File extension: {ext}')
# # PySNMP MIB module Wellfleet-CCT-NAME-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Wellfleet-CCT-NAME-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:32:56 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueSizeConstraint, ConstraintsUnion, ValueRangeConstraint, SingleValueConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "ConstraintsUnion", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsIntersection") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") Unsigned32, Counter32, ObjectIdentity, NotificationType, MibIdentifier, Integer32, Gauge32, IpAddress, ModuleIdentity, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64, TimeTicks, Bits = mibBuilder.importSymbols("SNMPv2-SMI", "Unsigned32", "Counter32", "ObjectIdentity", "NotificationType", "MibIdentifier", "Integer32", "Gauge32", "IpAddress", "ModuleIdentity", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64", "TimeTicks", "Bits") DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") wfServices, wfCircuitNameExtension = mibBuilder.importSymbols("Wellfleet-COMMON-MIB", "wfServices", "wfCircuitNameExtension") wfCircuitNameTable = MibTable((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3), ) if mibBuilder.loadTexts: wfCircuitNameTable.setStatus('mandatory') wfCircuitNameEntry = MibTableRow((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1), ).setIndexNames((0, "Wellfleet-CCT-NAME-MIB", "wfCircuitNumber")) if mibBuilder.loadTexts: wfCircuitNameEntry.setStatus('mandatory') wfCircuitNameDelete = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("create", 1), ("delete", 2))).clone('create')).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfCircuitNameDelete.setStatus('mandatory') wfCircuitNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: wfCircuitNumber.setStatus('mandatory') wfCircuitName = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 3), DisplayString()).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfCircuitName.setStatus('mandatory') wfCircuitIfType = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170))).clone(namedValues=NamedValues(("csmacd", 10), ("sync", 20), ("t1", 30), ("e1", 40), ("token", 50), ("fddi", 60), ("hssi", 70), ("mct1", 80), ("ds1e1", 90), ("none", 100), ("atm", 110), ("async", 120), ("isdn", 130), ("atmz", 140), ("bisync", 150), ("gre", 160), ("ds3e3", 170)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfCircuitIfType.setStatus('mandatory') wfCircuitProtoMap = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 5), OctetString()).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfCircuitProtoMap.setStatus('mandatory') wfCircuitType = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7))).clone(namedValues=NamedValues(("normal", 1), ("virtual", 2), ("master", 3), ("clip", 4), ("internal", 5), ("gre", 6), ("notrouted", 7))).clone('normal')).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfCircuitType.setStatus('mandatory') wfCircuitRelCctList = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 7), OctetString()).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfCircuitRelCctList.setStatus('mandatory') wfCircuitLineList = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 8), OctetString()).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfCircuitLineList.setStatus('mandatory') wfCircuitMultilineName = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 9), DisplayString()).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfCircuitMultilineName.setStatus('mandatory') wfCircuitTdmRes = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("notdmresources", 1), ("switchedh110", 2), ("routedh110", 3), ("cesh110", 4))).clone('notdmresources')).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfCircuitTdmRes.setStatus('mandatory') wfCircuitTdmCctInUse = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("notinuse", 1), ("inuse", 2))).clone('notinuse')).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfCircuitTdmCctInUse.setStatus('mandatory') wfLineMappingTable = MibTable((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 1), ) if mibBuilder.loadTexts: wfLineMappingTable.setStatus('mandatory') wfLineMappingEntry = MibTableRow((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 1, 1), ).setIndexNames((0, "Wellfleet-CCT-NAME-MIB", "wfLineMappingNumber")) if mibBuilder.loadTexts: wfLineMappingEntry.setStatus('mandatory') wfLineMappingDelete = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("created", 1), ("deleted", 2))).clone('created')).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfLineMappingDelete.setStatus('mandatory') wfLineMappingNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 1, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: wfLineMappingNumber.setStatus('mandatory') wfLineMappingCct = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 1, 1, 3), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfLineMappingCct.setStatus('mandatory') wfLineMappingDef = MibTableColumn((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 1, 1, 4), OctetString()).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfLineMappingDef.setStatus('mandatory') wfNode = MibIdentifier((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 2)) wfNodeDelete = MibScalar((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 2, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("created", 1), ("deleted", 2))).clone('created')).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfNodeDelete.setStatus('mandatory') wfNodeProtoMap = MibScalar((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 2, 2), OctetString()).setMaxAccess("readwrite") if mibBuilder.loadTexts: wfNodeProtoMap.setStatus('mandatory') mibBuilder.exportSymbols("Wellfleet-CCT-NAME-MIB", wfLineMappingDef=wfLineMappingDef, wfCircuitProtoMap=wfCircuitProtoMap, wfCircuitTdmCctInUse=wfCircuitTdmCctInUse, wfLineMappingDelete=wfLineMappingDelete, wfCircuitLineList=wfCircuitLineList, wfCircuitNumber=wfCircuitNumber, wfCircuitType=wfCircuitType, wfNodeProtoMap=wfNodeProtoMap, wfLineMappingCct=wfLineMappingCct, wfNode=wfNode, wfCircuitNameEntry=wfCircuitNameEntry, wfCircuitName=wfCircuitName, wfCircuitNameTable=wfCircuitNameTable, wfCircuitIfType=wfCircuitIfType, wfLineMappingEntry=wfLineMappingEntry, wfCircuitRelCctList=wfCircuitRelCctList, wfLineMappingNumber=wfLineMappingNumber, wfCircuitMultilineName=wfCircuitMultilineName, wfCircuitNameDelete=wfCircuitNameDelete, wfNodeDelete=wfNodeDelete, wfCircuitTdmRes=wfCircuitTdmRes, wfLineMappingTable=wfLineMappingTable)
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_union, value_range_constraint, single_value_constraint, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'ConstraintsUnion', 'ValueRangeConstraint', 'SingleValueConstraint', 'ConstraintsIntersection') (notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance') (unsigned32, counter32, object_identity, notification_type, mib_identifier, integer32, gauge32, ip_address, module_identity, iso, mib_scalar, mib_table, mib_table_row, mib_table_column, counter64, time_ticks, bits) = mibBuilder.importSymbols('SNMPv2-SMI', 'Unsigned32', 'Counter32', 'ObjectIdentity', 'NotificationType', 'MibIdentifier', 'Integer32', 'Gauge32', 'IpAddress', 'ModuleIdentity', 'iso', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter64', 'TimeTicks', 'Bits') (display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention') (wf_services, wf_circuit_name_extension) = mibBuilder.importSymbols('Wellfleet-COMMON-MIB', 'wfServices', 'wfCircuitNameExtension') wf_circuit_name_table = mib_table((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3)) if mibBuilder.loadTexts: wfCircuitNameTable.setStatus('mandatory') wf_circuit_name_entry = mib_table_row((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1)).setIndexNames((0, 'Wellfleet-CCT-NAME-MIB', 'wfCircuitNumber')) if mibBuilder.loadTexts: wfCircuitNameEntry.setStatus('mandatory') wf_circuit_name_delete = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('create', 1), ('delete', 2))).clone('create')).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfCircuitNameDelete.setStatus('mandatory') wf_circuit_number = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 2), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: wfCircuitNumber.setStatus('mandatory') wf_circuit_name = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 3), display_string()).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfCircuitName.setStatus('mandatory') wf_circuit_if_type = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170))).clone(namedValues=named_values(('csmacd', 10), ('sync', 20), ('t1', 30), ('e1', 40), ('token', 50), ('fddi', 60), ('hssi', 70), ('mct1', 80), ('ds1e1', 90), ('none', 100), ('atm', 110), ('async', 120), ('isdn', 130), ('atmz', 140), ('bisync', 150), ('gre', 160), ('ds3e3', 170)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfCircuitIfType.setStatus('mandatory') wf_circuit_proto_map = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 5), octet_string()).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfCircuitProtoMap.setStatus('mandatory') wf_circuit_type = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7))).clone(namedValues=named_values(('normal', 1), ('virtual', 2), ('master', 3), ('clip', 4), ('internal', 5), ('gre', 6), ('notrouted', 7))).clone('normal')).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfCircuitType.setStatus('mandatory') wf_circuit_rel_cct_list = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 7), octet_string()).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfCircuitRelCctList.setStatus('mandatory') wf_circuit_line_list = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 8), octet_string()).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfCircuitLineList.setStatus('mandatory') wf_circuit_multiline_name = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 9), display_string()).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfCircuitMultilineName.setStatus('mandatory') wf_circuit_tdm_res = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('notdmresources', 1), ('switchedh110', 2), ('routedh110', 3), ('cesh110', 4))).clone('notdmresources')).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfCircuitTdmRes.setStatus('mandatory') wf_circuit_tdm_cct_in_use = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 3, 1, 11), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('notinuse', 1), ('inuse', 2))).clone('notinuse')).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfCircuitTdmCctInUse.setStatus('mandatory') wf_line_mapping_table = mib_table((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 1)) if mibBuilder.loadTexts: wfLineMappingTable.setStatus('mandatory') wf_line_mapping_entry = mib_table_row((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 1, 1)).setIndexNames((0, 'Wellfleet-CCT-NAME-MIB', 'wfLineMappingNumber')) if mibBuilder.loadTexts: wfLineMappingEntry.setStatus('mandatory') wf_line_mapping_delete = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('created', 1), ('deleted', 2))).clone('created')).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfLineMappingDelete.setStatus('mandatory') wf_line_mapping_number = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 1, 1, 2), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: wfLineMappingNumber.setStatus('mandatory') wf_line_mapping_cct = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 1, 1, 3), integer32()).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfLineMappingCct.setStatus('mandatory') wf_line_mapping_def = mib_table_column((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 1, 1, 4), octet_string()).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfLineMappingDef.setStatus('mandatory') wf_node = mib_identifier((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 2)) wf_node_delete = mib_scalar((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 2, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('created', 1), ('deleted', 2))).clone('created')).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfNodeDelete.setStatus('mandatory') wf_node_proto_map = mib_scalar((1, 3, 6, 1, 4, 1, 18, 3, 3, 2, 9, 2, 2), octet_string()).setMaxAccess('readwrite') if mibBuilder.loadTexts: wfNodeProtoMap.setStatus('mandatory') mibBuilder.exportSymbols('Wellfleet-CCT-NAME-MIB', wfLineMappingDef=wfLineMappingDef, wfCircuitProtoMap=wfCircuitProtoMap, wfCircuitTdmCctInUse=wfCircuitTdmCctInUse, wfLineMappingDelete=wfLineMappingDelete, wfCircuitLineList=wfCircuitLineList, wfCircuitNumber=wfCircuitNumber, wfCircuitType=wfCircuitType, wfNodeProtoMap=wfNodeProtoMap, wfLineMappingCct=wfLineMappingCct, wfNode=wfNode, wfCircuitNameEntry=wfCircuitNameEntry, wfCircuitName=wfCircuitName, wfCircuitNameTable=wfCircuitNameTable, wfCircuitIfType=wfCircuitIfType, wfLineMappingEntry=wfLineMappingEntry, wfCircuitRelCctList=wfCircuitRelCctList, wfLineMappingNumber=wfLineMappingNumber, wfCircuitMultilineName=wfCircuitMultilineName, wfCircuitNameDelete=wfCircuitNameDelete, wfNodeDelete=wfNodeDelete, wfCircuitTdmRes=wfCircuitTdmRes, wfLineMappingTable=wfLineMappingTable)
word_size = 9 num_words = 256 words_per_row = 4 local_array_size = 15 output_extended_config = True output_datasheet_info = True netlist_only = True nominal_corner_only = True
word_size = 9 num_words = 256 words_per_row = 4 local_array_size = 15 output_extended_config = True output_datasheet_info = True netlist_only = True nominal_corner_only = True
class Solution: def twoSum(self, numbers: List[int], target: int) -> List[int]: if len(numbers) <= 1: return [None, None] idx2 = len(numbers)-1 idx1 = 0 while idx1 < idx2: if numbers[idx1] + numbers[idx2] == target: return [idx1+1, idx2+1] elif numbers[idx1] + numbers[idx2] <= target: idx1 += 1 else: idx2 -= 1
class Solution: def two_sum(self, numbers: List[int], target: int) -> List[int]: if len(numbers) <= 1: return [None, None] idx2 = len(numbers) - 1 idx1 = 0 while idx1 < idx2: if numbers[idx1] + numbers[idx2] == target: return [idx1 + 1, idx2 + 1] elif numbers[idx1] + numbers[idx2] <= target: idx1 += 1 else: idx2 -= 1
class SumUpException(Exception): pass class SumUpNoAccessCode(SumUpException): pass class SumUpAccessCodeExpired(SumUpException): pass
class Sumupexception(Exception): pass class Sumupnoaccesscode(SumUpException): pass class Sumupaccesscodeexpired(SumUpException): pass
# flake8: noqa test_train_config = {"training_parameters": {"EPOCHS": 50}} test_model_config = {"model_parameters": {"model_save_path": "modeloutput1"}} test_test_data = { "text": "what Homeowners Warranty Program means,what it applies to, what is its purpose?" } test_entities = [ {"text": "homeowners warranty program", "entity": "Fin_Corp", "start": 5, "end": 32} ] test_training_data = [ { "context": "what does Settlement means?", "entities": [ { "entity_value": "Settlement", "entity_type": "Fin_Corp", "start_index": 10, "end_index": 20, } ], }, { "context": "what does Home-Equity Loan means?", "entities": [ { "entity_value": "Home-Equity Loan", "entity_type": "Fin_Corp", "start_index": 10, "end_index": 26, } ], }, { "context": "what does Closed-Ended Credit stands for?", "entities": [ { "entity_value": "Closed-Ended Credit", "entity_type": "Fin_Corp", "start_index": 10, "end_index": 29, } ], }, { "context": "what does Adjustable-Rate Mortgage stands for?", "entities": [ { "entity_value": "Adjustable-Rate Mortgage", "entity_type": "Fin_Corp", "start_index": 10, "end_index": 34, } ], }, { "context": "what is the full form of Interest Cap ?", "entities": [ { "entity_value": "Interest Cap", "entity_type": "Fin_Corp", "start_index": 25, "end_index": 37, } ], }, { "context": "what is the full form of Title Insurance Policy ?", "entities": [ { "entity_value": "Title Insurance Policy", "entity_type": "Fin_Corp", "start_index": 25, "end_index": 47, } ], }, { "context": "what actually Mortgage Banker is ?", "entities": [ { "entity_value": "Mortgage Banker", "entity_type": "Fin_Corp", "start_index": 14, "end_index": 29, } ], }, { "context": "what actually Appraisal is ?", "entities": [ { "entity_value": "Appraisal", "entity_type": "Fin_Corp", "start_index": 14, "end_index": 23, } ], }, { "context": "what do Prepaid Items mean, explain the details", "entities": [ { "entity_value": "Prepaid Items", "entity_type": "Fin_Corp", "start_index": 8, "end_index": 21, } ], }, { "context": "what do Principal mean, explain the details", "entities": [ { "entity_value": "Principal", "entity_type": "Fin_Corp", "start_index": 8, "end_index": 17, } ], }, { "context": "I'm sorry, I'm not familiar with the meaning of Buyers Agent . What does that mean?", "entities": [ { "entity_value": "Buyers Agent", "entity_type": "Fin_Corp", "start_index": 48, "end_index": 60, } ], }, { "context": "I'm sorry, I'm not familiar with the meaning of Payment Cap . What does that mean?", "entities": [ { "entity_value": "Payment Cap", "entity_type": "Fin_Corp", "start_index": 48, "end_index": 59, } ], }, { "context": "Hello, Can you expand Sellers Agent ?", "entities": [ { "entity_value": "Sellers Agent", "entity_type": "Fin_Corp", "start_index": 22, "end_index": 35, } ], }, { "context": "Hello, Can you expand Floor ?", "entities": [ { "entity_value": "Floor", "entity_type": "Fin_Corp", "start_index": 22, "end_index": 27, } ], }, { "context": "What is Default ?", "entities": [ { "entity_value": "Default", "entity_type": "Fin_Corp", "start_index": 8, "end_index": 15, } ], }, { "context": "What is Amortization ?", "entities": [ { "entity_value": "Amortization", "entity_type": "Fin_Corp", "start_index": 8, "end_index": 20, } ], }, { "context": "What does Annual Percentage Rate mean?", "entities": [ { "entity_value": "Annual Percentage Rate", "entity_type": "Fin_Corp", "start_index": 10, "end_index": 32, } ], }, { "context": "What does Site-Built Housing mean?", "entities": [ { "entity_value": "Site-Built Housing", "entity_type": "Fin_Corp", "start_index": 10, "end_index": 28, } ], }, { "context": "Can you define what Amortization stands for and what it means?", "entities": [ { "entity_value": "Amortization", "entity_type": "Fin_Corp", "start_index": 20, "end_index": 32, } ], }, { "context": "Can you define what Fixed Interest Rate stands for and what it means?", "entities": [ { "entity_value": "Fixed Interest Rate", "entity_type": "Fin_Corp", "start_index": 20, "end_index": 39, } ], }, { "context": "I was looking over loan application could you explain what is meant by Point ?", "entities": [ { "entity_value": "Point", "entity_type": "Fin_Corp", "start_index": 71, "end_index": 76, } ], }, { "context": "I was looking over loan application could you explain what is meant by Net Income ?", "entities": [ { "entity_value": "Net Income", "entity_type": "Fin_Corp", "start_index": 71, "end_index": 81, } ], }, { "context": "I dont know what Interest stands for could you explain it clearly to me please?", "entities": [ { "entity_value": "Interest", "entity_type": "Fin_Corp", "start_index": 17, "end_index": 25, } ], }, { "context": "I dont know what Multiple Listing Service stands for could you explain it clearly to me please?", "entities": [ { "entity_value": "Multiple Listing Service", "entity_type": "Fin_Corp", "start_index": 17, "end_index": 41, } ], }, { "context": "what Homeowners Warranty Program means", "entities": [ { "entity_value": "Homeowners Warranty Program", "entity_type": "Fin_Corp", "start_index": 5, "end_index": 32, } ], }, { "context": "what Condominium means", "entities": [ { "entity_value": "Condominium", "entity_type": "Fin_Corp", "start_index": 5, "end_index": 16, } ], }, { "context": "Why is knowing your Interest Cap important?", "entities": [ { "entity_value": "Interest Cap", "entity_type": "Fin_Corp", "start_index": 20, "end_index": 32, } ], }, { "context": "Why is knowing your Credit Bureau important?", "entities": [ { "entity_value": "Credit Bureau", "entity_type": "Fin_Corp", "start_index": 20, "end_index": 33, } ], }, { "context": "Please explain what you mean by Qualifying Ratios .", "entities": [ { "entity_value": "Qualifying Ratios", "entity_type": "Fin_Corp", "start_index": 32, "end_index": 49, } ], }, { "context": "Please explain what you mean by Closed-Ended Credit .", "entities": [ { "entity_value": "Closed-Ended Credit", "entity_type": "Fin_Corp", "start_index": 32, "end_index": 51, } ], }, { "context": "please explain what is VA Loan in detail.", "entities": [ { "entity_value": "VA Loan", "entity_type": "Fin_Corp", "start_index": 23, "end_index": 30, } ], }, { "context": "please explain what is Agent in detail.", "entities": [ { "entity_value": "Agent", "entity_type": "Fin_Corp", "start_index": 23, "end_index": 28, } ], }, { "context": "Could you please elaborate Lease-Purchase ?", "entities": [ { "entity_value": "Lease-Purchase", "entity_type": "Fin_Corp", "start_index": 27, "end_index": 41, } ], }, { "context": "Could you please elaborate Interest Rate ?", "entities": [ { "entity_value": "Interest Rate", "entity_type": "Fin_Corp", "start_index": 27, "end_index": 40, } ], }, { "context": "Can you explain Delinquency to me?", "entities": [ { "entity_value": "Delinquency", "entity_type": "Fin_Corp", "start_index": 16, "end_index": 27, } ], }, { "context": "Can you explain Balloon Mortgage to me?", "entities": [ { "entity_value": "Balloon Mortgage", "entity_type": "Fin_Corp", "start_index": 16, "end_index": 32, } ], }, { "context": "what does Prepaid Items really mean", "entities": [ { "entity_value": "Prepaid Items", "entity_type": "Fin_Corp", "start_index": 10, "end_index": 23, } ], }, { "context": "what does Loan-to-Value Ratio really mean", "entities": [ { "entity_value": "Loan-to-Value Ratio", "entity_type": "Fin_Corp", "start_index": 10, "end_index": 29, } ], }, { "context": "Can you explain to me,please,what Homeowners Warranty Program means,what it applies to,what is its purpose? Thank you", "entities": [ { "entity_value": "Homeowners Warranty Program", "entity_type": "Fin_Corp", "start_index": 34, "end_index": 61, } ], }, { "context": "Can you explain to me,please,what Balloon Mortgage means,what it applies to,what is its purpose? Thank you", "entities": [ { "entity_value": "Balloon Mortgage", "entity_type": "Fin_Corp", "start_index": 34, "end_index": 50, } ], }, { "context": "what's the meaning of Mortgagee and how can i use it?", "entities": [ { "entity_value": "Mortgagee", "entity_type": "Fin_Corp", "start_index": 22, "end_index": 31, } ], }, { "context": "what's the meaning of Prepayment Penalty and how can i use it?", "entities": [ { "entity_value": "Prepayment Penalty", "entity_type": "Fin_Corp", "start_index": 22, "end_index": 40, } ], }, { "context": "Ive not heard that before. What does Interest Cap mean?", "entities": [ { "entity_value": "Interest Cap", "entity_type": "Fin_Corp", "start_index": 37, "end_index": 49, } ], }, { "context": "Ive not heard that before. What does Lender mean?", "entities": [ { "entity_value": "Lender", "entity_type": "Fin_Corp", "start_index": 37, "end_index": 43, } ], }, { "context": "Can you elaborate on what Mortgage Banker is about?", "entities": [ { "entity_value": "Mortgage Banker", "entity_type": "Fin_Corp", "start_index": 26, "end_index": 41, } ], }, { "context": "Can you elaborate on what Assessment is about?", "entities": [ { "entity_value": "Assessment", "entity_type": "Fin_Corp", "start_index": 26, "end_index": 36, } ], }, { "context": "I've never heard of Due-on-Sale , can you explain it to me in an easy way for me to understand?", "entities": [ { "entity_value": "Due-on-Sale", "entity_type": "Fin_Corp", "start_index": 20, "end_index": 31, } ], }, { "context": "I've never heard of Trust , can you explain it to me in an easy way for me to understand?", "entities": [ { "entity_value": "Trust", "entity_type": "Fin_Corp", "start_index": 20, "end_index": 25, } ], }, { "context": "How does my Market Value effect me?", "entities": [ { "entity_value": "Market Value", "entity_type": "Fin_Corp", "start_index": 12, "end_index": 24, } ], }, { "context": "How does my Balloon Mortgage effect me?", "entities": [ { "entity_value": "Balloon Mortgage", "entity_type": "Fin_Corp", "start_index": 12, "end_index": 28, } ], }, ]
test_train_config = {'training_parameters': {'EPOCHS': 50}} test_model_config = {'model_parameters': {'model_save_path': 'modeloutput1'}} test_test_data = {'text': 'what Homeowners Warranty Program means,what it applies to, what is its purpose?'} test_entities = [{'text': 'homeowners warranty program', 'entity': 'Fin_Corp', 'start': 5, 'end': 32}] test_training_data = [{'context': 'what does Settlement means?', 'entities': [{'entity_value': 'Settlement', 'entity_type': 'Fin_Corp', 'start_index': 10, 'end_index': 20}]}, {'context': 'what does Home-Equity Loan means?', 'entities': [{'entity_value': 'Home-Equity Loan', 'entity_type': 'Fin_Corp', 'start_index': 10, 'end_index': 26}]}, {'context': 'what does Closed-Ended Credit stands for?', 'entities': [{'entity_value': 'Closed-Ended Credit', 'entity_type': 'Fin_Corp', 'start_index': 10, 'end_index': 29}]}, {'context': 'what does Adjustable-Rate Mortgage stands for?', 'entities': [{'entity_value': 'Adjustable-Rate Mortgage', 'entity_type': 'Fin_Corp', 'start_index': 10, 'end_index': 34}]}, {'context': 'what is the full form of Interest Cap ?', 'entities': [{'entity_value': 'Interest Cap', 'entity_type': 'Fin_Corp', 'start_index': 25, 'end_index': 37}]}, {'context': 'what is the full form of Title Insurance Policy ?', 'entities': [{'entity_value': 'Title Insurance Policy', 'entity_type': 'Fin_Corp', 'start_index': 25, 'end_index': 47}]}, {'context': 'what actually Mortgage Banker is ?', 'entities': [{'entity_value': 'Mortgage Banker', 'entity_type': 'Fin_Corp', 'start_index': 14, 'end_index': 29}]}, {'context': 'what actually Appraisal is ?', 'entities': [{'entity_value': 'Appraisal', 'entity_type': 'Fin_Corp', 'start_index': 14, 'end_index': 23}]}, {'context': 'what do Prepaid Items mean, explain the details', 'entities': [{'entity_value': 'Prepaid Items', 'entity_type': 'Fin_Corp', 'start_index': 8, 'end_index': 21}]}, {'context': 'what do Principal mean, explain the details', 'entities': [{'entity_value': 'Principal', 'entity_type': 'Fin_Corp', 'start_index': 8, 'end_index': 17}]}, {'context': "I'm sorry, I'm not familiar with the meaning of Buyers Agent . What does that mean?", 'entities': [{'entity_value': 'Buyers Agent', 'entity_type': 'Fin_Corp', 'start_index': 48, 'end_index': 60}]}, {'context': "I'm sorry, I'm not familiar with the meaning of Payment Cap . What does that mean?", 'entities': [{'entity_value': 'Payment Cap', 'entity_type': 'Fin_Corp', 'start_index': 48, 'end_index': 59}]}, {'context': 'Hello, Can you expand Sellers Agent ?', 'entities': [{'entity_value': 'Sellers Agent', 'entity_type': 'Fin_Corp', 'start_index': 22, 'end_index': 35}]}, {'context': 'Hello, Can you expand Floor ?', 'entities': [{'entity_value': 'Floor', 'entity_type': 'Fin_Corp', 'start_index': 22, 'end_index': 27}]}, {'context': 'What is Default ?', 'entities': [{'entity_value': 'Default', 'entity_type': 'Fin_Corp', 'start_index': 8, 'end_index': 15}]}, {'context': 'What is Amortization ?', 'entities': [{'entity_value': 'Amortization', 'entity_type': 'Fin_Corp', 'start_index': 8, 'end_index': 20}]}, {'context': 'What does Annual Percentage Rate mean?', 'entities': [{'entity_value': 'Annual Percentage Rate', 'entity_type': 'Fin_Corp', 'start_index': 10, 'end_index': 32}]}, {'context': 'What does Site-Built Housing mean?', 'entities': [{'entity_value': 'Site-Built Housing', 'entity_type': 'Fin_Corp', 'start_index': 10, 'end_index': 28}]}, {'context': 'Can you define what Amortization stands for and what it means?', 'entities': [{'entity_value': 'Amortization', 'entity_type': 'Fin_Corp', 'start_index': 20, 'end_index': 32}]}, {'context': 'Can you define what Fixed Interest Rate stands for and what it means?', 'entities': [{'entity_value': 'Fixed Interest Rate', 'entity_type': 'Fin_Corp', 'start_index': 20, 'end_index': 39}]}, {'context': 'I was looking over loan application could you explain what is meant by Point ?', 'entities': [{'entity_value': 'Point', 'entity_type': 'Fin_Corp', 'start_index': 71, 'end_index': 76}]}, {'context': 'I was looking over loan application could you explain what is meant by Net Income ?', 'entities': [{'entity_value': 'Net Income', 'entity_type': 'Fin_Corp', 'start_index': 71, 'end_index': 81}]}, {'context': 'I dont know what Interest stands for could you explain it clearly to me please?', 'entities': [{'entity_value': 'Interest', 'entity_type': 'Fin_Corp', 'start_index': 17, 'end_index': 25}]}, {'context': 'I dont know what Multiple Listing Service stands for could you explain it clearly to me please?', 'entities': [{'entity_value': 'Multiple Listing Service', 'entity_type': 'Fin_Corp', 'start_index': 17, 'end_index': 41}]}, {'context': 'what Homeowners Warranty Program means', 'entities': [{'entity_value': 'Homeowners Warranty Program', 'entity_type': 'Fin_Corp', 'start_index': 5, 'end_index': 32}]}, {'context': 'what Condominium means', 'entities': [{'entity_value': 'Condominium', 'entity_type': 'Fin_Corp', 'start_index': 5, 'end_index': 16}]}, {'context': 'Why is knowing your Interest Cap important?', 'entities': [{'entity_value': 'Interest Cap', 'entity_type': 'Fin_Corp', 'start_index': 20, 'end_index': 32}]}, {'context': 'Why is knowing your Credit Bureau important?', 'entities': [{'entity_value': 'Credit Bureau', 'entity_type': 'Fin_Corp', 'start_index': 20, 'end_index': 33}]}, {'context': 'Please explain what you mean by Qualifying Ratios .', 'entities': [{'entity_value': 'Qualifying Ratios', 'entity_type': 'Fin_Corp', 'start_index': 32, 'end_index': 49}]}, {'context': 'Please explain what you mean by Closed-Ended Credit .', 'entities': [{'entity_value': 'Closed-Ended Credit', 'entity_type': 'Fin_Corp', 'start_index': 32, 'end_index': 51}]}, {'context': 'please explain what is VA Loan in detail.', 'entities': [{'entity_value': 'VA Loan', 'entity_type': 'Fin_Corp', 'start_index': 23, 'end_index': 30}]}, {'context': 'please explain what is Agent in detail.', 'entities': [{'entity_value': 'Agent', 'entity_type': 'Fin_Corp', 'start_index': 23, 'end_index': 28}]}, {'context': 'Could you please elaborate Lease-Purchase ?', 'entities': [{'entity_value': 'Lease-Purchase', 'entity_type': 'Fin_Corp', 'start_index': 27, 'end_index': 41}]}, {'context': 'Could you please elaborate Interest Rate ?', 'entities': [{'entity_value': 'Interest Rate', 'entity_type': 'Fin_Corp', 'start_index': 27, 'end_index': 40}]}, {'context': 'Can you explain Delinquency to me?', 'entities': [{'entity_value': 'Delinquency', 'entity_type': 'Fin_Corp', 'start_index': 16, 'end_index': 27}]}, {'context': 'Can you explain Balloon Mortgage to me?', 'entities': [{'entity_value': 'Balloon Mortgage', 'entity_type': 'Fin_Corp', 'start_index': 16, 'end_index': 32}]}, {'context': 'what does Prepaid Items really mean', 'entities': [{'entity_value': 'Prepaid Items', 'entity_type': 'Fin_Corp', 'start_index': 10, 'end_index': 23}]}, {'context': 'what does Loan-to-Value Ratio really mean', 'entities': [{'entity_value': 'Loan-to-Value Ratio', 'entity_type': 'Fin_Corp', 'start_index': 10, 'end_index': 29}]}, {'context': 'Can you explain to me,please,what Homeowners Warranty Program means,what it applies to,what is its purpose? Thank you', 'entities': [{'entity_value': 'Homeowners Warranty Program', 'entity_type': 'Fin_Corp', 'start_index': 34, 'end_index': 61}]}, {'context': 'Can you explain to me,please,what Balloon Mortgage means,what it applies to,what is its purpose? Thank you', 'entities': [{'entity_value': 'Balloon Mortgage', 'entity_type': 'Fin_Corp', 'start_index': 34, 'end_index': 50}]}, {'context': "what's the meaning of Mortgagee and how can i use it?", 'entities': [{'entity_value': 'Mortgagee', 'entity_type': 'Fin_Corp', 'start_index': 22, 'end_index': 31}]}, {'context': "what's the meaning of Prepayment Penalty and how can i use it?", 'entities': [{'entity_value': 'Prepayment Penalty', 'entity_type': 'Fin_Corp', 'start_index': 22, 'end_index': 40}]}, {'context': 'Ive not heard that before. What does Interest Cap mean?', 'entities': [{'entity_value': 'Interest Cap', 'entity_type': 'Fin_Corp', 'start_index': 37, 'end_index': 49}]}, {'context': 'Ive not heard that before. What does Lender mean?', 'entities': [{'entity_value': 'Lender', 'entity_type': 'Fin_Corp', 'start_index': 37, 'end_index': 43}]}, {'context': 'Can you elaborate on what Mortgage Banker is about?', 'entities': [{'entity_value': 'Mortgage Banker', 'entity_type': 'Fin_Corp', 'start_index': 26, 'end_index': 41}]}, {'context': 'Can you elaborate on what Assessment is about?', 'entities': [{'entity_value': 'Assessment', 'entity_type': 'Fin_Corp', 'start_index': 26, 'end_index': 36}]}, {'context': "I've never heard of Due-on-Sale , can you explain it to me in an easy way for me to understand?", 'entities': [{'entity_value': 'Due-on-Sale', 'entity_type': 'Fin_Corp', 'start_index': 20, 'end_index': 31}]}, {'context': "I've never heard of Trust , can you explain it to me in an easy way for me to understand?", 'entities': [{'entity_value': 'Trust', 'entity_type': 'Fin_Corp', 'start_index': 20, 'end_index': 25}]}, {'context': 'How does my Market Value effect me?', 'entities': [{'entity_value': 'Market Value', 'entity_type': 'Fin_Corp', 'start_index': 12, 'end_index': 24}]}, {'context': 'How does my Balloon Mortgage effect me?', 'entities': [{'entity_value': 'Balloon Mortgage', 'entity_type': 'Fin_Corp', 'start_index': 12, 'end_index': 28}]}]
def entrance(): '''This is the initial room the player will begin their adventure.''' pass def orange_rm_1(): '''Todo: red key(hidden in desk drawer) health(desk top) desk rat (24% damage) red door ''' pass def red_rm_2(): '''locked entrance- requires red key to do: skull of meatboy (20 questions) bamboo (blowgun) desk dr. fetus (1% dmg atk, runs away after attack. mentions hidden passage) ''' pass def blue_rm_1(): '''to do list: book case (hidden passage) health (25%) shield (50% damage decrease) ''' pass def blue_rm_2(): '''to do list: axe for boss fight red key (bowl) locked orange door (to main boss) ''' pass def red_rm_1(): '''to do list: door into room is locked (orange key hidden in red_rm_1) note from file dart bread (inv - must use) ''' pass def red_rm_3(): '''to do list: stick (weapon) health (25%) ''' pass def red_rm_4(): '''banquet hall table food (invokes rat to attack if eaten/taken) rat (24% dmg atk) chair ''' pass def giant_toddler(): '''nursery atmosphere to do: giant toddler rattle boss room key ''' pass def watermelon_rex(): '''den of whoever runs this mad house pink key health animal heads on walls (interactive - one head breaks upon engaging boss) watermelon_rex fire place giant mahogany desk ''' pass
def entrance(): """This is the initial room the player will begin their adventure.""" pass def orange_rm_1(): """Todo: red key(hidden in desk drawer) health(desk top) desk rat (24% damage) red door """ pass def red_rm_2(): """locked entrance- requires red key to do: skull of meatboy (20 questions) bamboo (blowgun) desk dr. fetus (1% dmg atk, runs away after attack. mentions hidden passage) """ pass def blue_rm_1(): """to do list: book case (hidden passage) health (25%) shield (50% damage decrease) """ pass def blue_rm_2(): """to do list: axe for boss fight red key (bowl) locked orange door (to main boss) """ pass def red_rm_1(): """to do list: door into room is locked (orange key hidden in red_rm_1) note from file dart bread (inv - must use) """ pass def red_rm_3(): """to do list: stick (weapon) health (25%) """ pass def red_rm_4(): """banquet hall table food (invokes rat to attack if eaten/taken) rat (24% dmg atk) chair """ pass def giant_toddler(): """nursery atmosphere to do: giant toddler rattle boss room key """ pass def watermelon_rex(): """den of whoever runs this mad house pink key health animal heads on walls (interactive - one head breaks upon engaging boss) watermelon_rex fire place giant mahogany desk """ pass
def main(request, response): headers = [("Content-Type", "text/javascript")] milk = request.cookies.first("milk", None) if milk is None: return headers, "var included = false;" elif milk.value == "yes": return headers, "var included = true;" return headers, "var included = false;"
def main(request, response): headers = [('Content-Type', 'text/javascript')] milk = request.cookies.first('milk', None) if milk is None: return (headers, 'var included = false;') elif milk.value == 'yes': return (headers, 'var included = true;') return (headers, 'var included = false;')
CORRECT_PIN = "1234" MAX_TRIES = 3 tries_left = MAX_TRIES pin = input(f"Insert your pni ({tries_left} tries left): ") while tries_left > 1 and pin != CORRECT_PIN: tries_left -= 1 print("Your PIN is incorrect.") pin = input(f"Insert your pni ({tries_left} tries left): ") if pin == CORRECT_PIN: print("Your PIN is correct") else: print("Your bank card is blocked")
correct_pin = '1234' max_tries = 3 tries_left = MAX_TRIES pin = input(f'Insert your pni ({tries_left} tries left): ') while tries_left > 1 and pin != CORRECT_PIN: tries_left -= 1 print('Your PIN is incorrect.') pin = input(f'Insert your pni ({tries_left} tries left): ') if pin == CORRECT_PIN: print('Your PIN is correct') else: print('Your bank card is blocked')
# # Solution to Project Euler problem 73 # Copyright (c) Project Nayuki. All rights reserved. # # https://www.nayuki.io/page/project-euler-solutions # https://github.com/nayuki/Project-Euler-solutions # # The Stern-Brocot tree is an infinite binary search tree of all positive rational numbers, # where each number appears only once and is in lowest terms. # It is formed by starting with the two sentinels 0/1 and 1/1. Iterating infinitely in any order, # between any two currently adjacent fractions Ln/Ld and Rn/Rd, insert a new fraction (Ln+Rn)/(Ld+Rd). # See MathWorld for a visualization: http://mathworld.wolfram.com/Stern-BrocotTree.html # # The natural algorithm is as follows: # # Counts the number of reduced fractions n/d such that leftN/leftD < n/d < rightN/rightD and d <= 12000. # # leftN/leftD and rightN/rightD must be adjacent in the Stern-Brocot tree at some point in the generation process. # def stern_brocot_count(leftn, leftd, rightn, rightd): # d = leftd + rightd # if d > 12000: # return 0 # else: # n = leftn + rightn # return 1 + stern_brocot_count(leftn, leftd, n, d) + stern_brocot_count(n, d, rightn, rightd) # But instead we use depth-first search on an explicit stack, because having # a large number of stack frames seems to be supported on Linux but not on Windows. def compute(): ans = 0 stack = [(1, 3, 1, 2)] while len(stack) > 0: leftn, leftd, rightn, rightd = stack.pop() d = leftd + rightd if d <= 12000: n = leftn + rightn ans += 1 stack.append((n, d, rightn, rightd)) stack.append((leftn, leftd, n, d)) return str(ans) if __name__ == "__main__": print(compute())
def compute(): ans = 0 stack = [(1, 3, 1, 2)] while len(stack) > 0: (leftn, leftd, rightn, rightd) = stack.pop() d = leftd + rightd if d <= 12000: n = leftn + rightn ans += 1 stack.append((n, d, rightn, rightd)) stack.append((leftn, leftd, n, d)) return str(ans) if __name__ == '__main__': print(compute())
class BaseSiteCheckerException(Exception): pass class ErrorStopMsgLimit(BaseSiteCheckerException): pass
class Basesitecheckerexception(Exception): pass class Errorstopmsglimit(BaseSiteCheckerException): pass
def get_safe_balanced_split(target, train_ratio=0.8, get_test_indices=True, shuffle=False, seed=None): classes, counts = np.unique(target, return_counts=True) num_per_class = float(len(target))*float(train_ratio)/float(len(classes)) if num_per_class > np.min(counts): print("Insufficient data to produce a balanced training data split.") print("Classes found {}".format(classes)) print("Classes count {}".format(counts)) ts = float(train_ratio*np.min(counts)*len(classes)) / float(len(target)) print("train_ratio is reset from {} to {}".format(train_ratio, ts)) train_ratio = ts num_per_class = float(len(target))*float(train_ratio)/float(len(classes)) num_per_class = int(num_per_class) print("Data splitting on {} classes and returning {} per class".format(len(classes), num_per_class )) # get indices train_indices = [] for c in classes: if seed is not None: np.random.seed(seed) c_idxs = np.where(target==c)[0] c_idxs = np.random.choice(c_idxs, num_per_class, replace=False) train_indices.extend(c_idxs) # get test indices test_indices = None if get_test_indices: test_indices = list(set(range(len(target))) - set(train_indices)) # shuffle if shuffle: train_indices = random.shuffle(train_indices) if test_indices is not None: test_indices = random.shuffle(test_indices) return train_indices, test_indices
def get_safe_balanced_split(target, train_ratio=0.8, get_test_indices=True, shuffle=False, seed=None): (classes, counts) = np.unique(target, return_counts=True) num_per_class = float(len(target)) * float(train_ratio) / float(len(classes)) if num_per_class > np.min(counts): print('Insufficient data to produce a balanced training data split.') print('Classes found {}'.format(classes)) print('Classes count {}'.format(counts)) ts = float(train_ratio * np.min(counts) * len(classes)) / float(len(target)) print('train_ratio is reset from {} to {}'.format(train_ratio, ts)) train_ratio = ts num_per_class = float(len(target)) * float(train_ratio) / float(len(classes)) num_per_class = int(num_per_class) print('Data splitting on {} classes and returning {} per class'.format(len(classes), num_per_class)) train_indices = [] for c in classes: if seed is not None: np.random.seed(seed) c_idxs = np.where(target == c)[0] c_idxs = np.random.choice(c_idxs, num_per_class, replace=False) train_indices.extend(c_idxs) test_indices = None if get_test_indices: test_indices = list(set(range(len(target))) - set(train_indices)) if shuffle: train_indices = random.shuffle(train_indices) if test_indices is not None: test_indices = random.shuffle(test_indices) return (train_indices, test_indices)
print("Welcome to the Multiplication/Exponent Table App") print() name = input("Hello, What is your name: ") number = float(input("What number would you like to work with: ")) name = name.strip() print("Multiplication Table For {}".format(number)) print() print("\t\t1.0 * {} = {:.2f}".format(number, number*1.0)) print("\t\t2.0 * {} = {:.2f}".format(number, number*2.0)) print("\t\t3.0 * {} = {:.2f}".format(number, number*3.0)) print("\t\t4.0 * {} = {:.2f}".format(number, number*4.0)) print("\t\t5.0 * {} = {:.2f}".format(number, number*5.0)) print("\t\t6.0 * {} = {:.2f}".format(number, number*6.0)) print("\t\t7.0 * {} = {:.2f}".format(number, number*7.0)) print("\t\t8.0 * {} = {:.2f}".format(number, number*8.0)) print("\t\t9.0 * {} = {:.2f}".format(number, number*9.0)) print() print("Exponent Table For {}".format(number)) print() print("\t\t{} ** 1 = {:.2f}".format(number, number**1)) print("\t\t{} ** 2 = {:.2f}".format(number, number**2)) print("\t\t{} ** 3 = {:.2f}".format(number, number**3)) print("\t\t{} ** 4 = {:.2f}".format(number, number**4)) print("\t\t{} ** 5 = {:.2f}".format(number, number**5)) print("\t\t{} ** 6 = {:.2f}".format(number, number**6)) print("\t\t{} ** 7 = {:.2f}".format(number, number**7)) print("\t\t{} ** 8 = {:.2f}".format(number, number**8)) print("\t\t{} ** 9 = {:.2f}".format(number, number**9)) print() message = "{} Math is cool!".format(name) print(message) print("\t{}".format(message.lower())) print("\t\t{}".format(message.title())) print("\t\t\t{}".format(message.lower()))
print('Welcome to the Multiplication/Exponent Table App') print() name = input('Hello, What is your name: ') number = float(input('What number would you like to work with: ')) name = name.strip() print('Multiplication Table For {}'.format(number)) print() print('\t\t1.0 * {} = {:.2f}'.format(number, number * 1.0)) print('\t\t2.0 * {} = {:.2f}'.format(number, number * 2.0)) print('\t\t3.0 * {} = {:.2f}'.format(number, number * 3.0)) print('\t\t4.0 * {} = {:.2f}'.format(number, number * 4.0)) print('\t\t5.0 * {} = {:.2f}'.format(number, number * 5.0)) print('\t\t6.0 * {} = {:.2f}'.format(number, number * 6.0)) print('\t\t7.0 * {} = {:.2f}'.format(number, number * 7.0)) print('\t\t8.0 * {} = {:.2f}'.format(number, number * 8.0)) print('\t\t9.0 * {} = {:.2f}'.format(number, number * 9.0)) print() print('Exponent Table For {}'.format(number)) print() print('\t\t{} ** 1 = {:.2f}'.format(number, number ** 1)) print('\t\t{} ** 2 = {:.2f}'.format(number, number ** 2)) print('\t\t{} ** 3 = {:.2f}'.format(number, number ** 3)) print('\t\t{} ** 4 = {:.2f}'.format(number, number ** 4)) print('\t\t{} ** 5 = {:.2f}'.format(number, number ** 5)) print('\t\t{} ** 6 = {:.2f}'.format(number, number ** 6)) print('\t\t{} ** 7 = {:.2f}'.format(number, number ** 7)) print('\t\t{} ** 8 = {:.2f}'.format(number, number ** 8)) print('\t\t{} ** 9 = {:.2f}'.format(number, number ** 9)) print() message = '{} Math is cool!'.format(name) print(message) print('\t{}'.format(message.lower())) print('\t\t{}'.format(message.title())) print('\t\t\t{}'.format(message.lower()))
# Live preview Markdown and reStructuredText files as HTML in a web browser. # # Author: Peter Odding <peter@peterodding.com> # Last Change: April 12, 2018 # URL: https://github.com/xolox/python-preview-markup __version__ = '0.3.3'
__version__ = '0.3.3'
# # These methods are working on multiple processors # that can be located remotely # class Bridges: @staticmethod def create(master=None, workers=None, name=None): raise NotImplementedError @staticmethod def set(master=None, workers=None, name=None): raise NotImplementedError @staticmethod def list(hosts=None): raise NotImplementedError @staticmethod def check(hosts=None): raise NotImplementedError @staticmethod def restart(host=None): raise NotImplementedError
class Bridges: @staticmethod def create(master=None, workers=None, name=None): raise NotImplementedError @staticmethod def set(master=None, workers=None, name=None): raise NotImplementedError @staticmethod def list(hosts=None): raise NotImplementedError @staticmethod def check(hosts=None): raise NotImplementedError @staticmethod def restart(host=None): raise NotImplementedError
for index in range(1,101): # if index % 15 == 0: # print("fifteen") if index % 3 == 0 and index % 5 == 0 : print("fifteen") elif index % 3 == 0: print("three") elif index % 5 == 0: print("five") else: print(index)
for index in range(1, 101): if index % 3 == 0 and index % 5 == 0: print('fifteen') elif index % 3 == 0: print('three') elif index % 5 == 0: print('five') else: print(index)
class Solution: def rob(self, nums): if not nums: return 0 values = [0] * len(nums) for i in range(len(nums)): if i == 0: values[i] = max(values[i], nums[i]) elif i == 1: values[i] = max(values[i-1], nums[i]) else: values[i] = max(values[i-2] + nums[i], values[i-1]) return values[-1] s = Solution() print(s.rob([2,7,9,3,1]))
class Solution: def rob(self, nums): if not nums: return 0 values = [0] * len(nums) for i in range(len(nums)): if i == 0: values[i] = max(values[i], nums[i]) elif i == 1: values[i] = max(values[i - 1], nums[i]) else: values[i] = max(values[i - 2] + nums[i], values[i - 1]) return values[-1] s = solution() print(s.rob([2, 7, 9, 3, 1]))
MASTER_PROCESS_RANK = 0 # Only meaningful if webscraper is run with multiple processes. Here we use rank = 0 for master process; however we can set it to any value in [0, nprocs-1]. READING_RATIO_FOR_INPUT_CSVs = 1 # It represents how much of the input files (in csv format for now) we should process. MUST BE BETWEEN [0, 1]. For example 0.1 means; process 1/10th of each of the input files (in terms of rows) and 1 means read them all. NUMBER_OF_REPEATS_TIMEIT = 1 CREATE_WORD_CLOUD = True CREATE_BAG_OF_WORDS = True CREATE_SENTIMENT_ANALYSIS_RESULTS = True
master_process_rank = 0 reading_ratio_for_input_cs_vs = 1 number_of_repeats_timeit = 1 create_word_cloud = True create_bag_of_words = True create_sentiment_analysis_results = True
# # @lc app=leetcode.cn id=1689 lang=python3 # # [1689] detect-pattern-of-length-m-repeated-k-or-more-times # None # @lc code=end
None
print("Raadsel 1:", "\n Wanneer leefde de oudste persoon ter wereld?") guess = input() #"TUSSEN GEBOORTE en dood" # input () guess_words = [] for g in guess.split(): guess_words.append(g.lower()) answer_words = ["tussen", "geboorte", "dood"] incorrect = False for word in answer_words: if word not in guess_words: incorrect = True if incorrect == True: print ("Jammer, je hebt het fout geraden,", "het antwoord was \n tussen zijn geboorte en zijn dood") else: print ("Goed gedaan, je hebt het geraden.")
print('Raadsel 1:', '\n Wanneer leefde de oudste persoon ter wereld?') guess = input() guess_words = [] for g in guess.split(): guess_words.append(g.lower()) answer_words = ['tussen', 'geboorte', 'dood'] incorrect = False for word in answer_words: if word not in guess_words: incorrect = True if incorrect == True: print('Jammer, je hebt het fout geraden,', 'het antwoord was \n tussen zijn geboorte en zijn dood') else: print('Goed gedaan, je hebt het geraden.')
# Problem code def countAndSay(n): if n == 1: return "1" current = "1" for i in range(2, n + 1): current = helper(current) return current def helper(current): group_count = 1 group_member = current[0] result = "" for i in range(1, len(current)): if current[i] == group_member: group_count += 1 continue else: result += str(group_count) result += str(group_member) group_count = 1 group_member = current[i] result += str(group_count) result += str(group_member) return result # Setup print(countAndSay(4))
def count_and_say(n): if n == 1: return '1' current = '1' for i in range(2, n + 1): current = helper(current) return current def helper(current): group_count = 1 group_member = current[0] result = '' for i in range(1, len(current)): if current[i] == group_member: group_count += 1 continue else: result += str(group_count) result += str(group_member) group_count = 1 group_member = current[i] result += str(group_count) result += str(group_member) return result print(count_and_say(4))
# A classroom consists of N students, whose friendships can be represented in # an adjacency list. For example, the following descibes a situation where 0 # is friends with 1 and 2, 3 is friends with 6, and so on. # {0: [1, 2], # 1: [0, 5], # 2: [0], # 3: [6], # 4: [], # 5: [1], # 6: [3]} # Each student can be placed in a friend group, which can be defined as the # transitive closure of that student's friendship relations. In other words, # this is the smallest set such that no student in the group has any friends # outside this group. For the example above, the friend groups would be # {0, 1, 2, 5}, {3, 6}, {4}. # Given a friendship list such as the one above, determine the number of # friend groups in the class. def friend_group(adjacency): groups = [] mapping = {} for i in adjacency: if i in mapping: continue for adj in adjacency[i]: if adj in mapping: groups[mapping[adj]].add(i) mapping[i] = mapping[adj] if i not in mapping: mapping[i] = len(groups) groups.append({i}) return groups if __name__ == '__main__': print(friend_group({ 0: [1, 2], 1: [0, 5], 2: [0], 3: [6], 4: [], 5: [1], 6: [3] }))
def friend_group(adjacency): groups = [] mapping = {} for i in adjacency: if i in mapping: continue for adj in adjacency[i]: if adj in mapping: groups[mapping[adj]].add(i) mapping[i] = mapping[adj] if i not in mapping: mapping[i] = len(groups) groups.append({i}) return groups if __name__ == '__main__': print(friend_group({0: [1, 2], 1: [0, 5], 2: [0], 3: [6], 4: [], 5: [1], 6: [3]}))
class Solution(object): def longestCommonSubsequence(self, text1, text2): if not text1 or not text2: return 0 m = len(text1) n = len(text2) dp = [[0]*(n+1) for _ in range(m+1)] for i in range(1,m+1): for j in range(1,n+1): if text1[i-1] == text2[j-1]: dp[i][j] = 1 + dp[i-1][j-1] else: dp[i][j] = max(dp[i-1][j],dp[i][j-1]) return dp[m][n]
class Solution(object): def longest_common_subsequence(self, text1, text2): if not text1 or not text2: return 0 m = len(text1) n = len(text2) dp = [[0] * (n + 1) for _ in range(m + 1)] for i in range(1, m + 1): for j in range(1, n + 1): if text1[i - 1] == text2[j - 1]: dp[i][j] = 1 + dp[i - 1][j - 1] else: dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) return dp[m][n]
class Printer(object): def __init__(self, sort_keys=None, order=None, header=None): self.sort_keys = sort_keys self.order = order self.header = header def print(self, d, format='table'): print(self.value(d,format=format)) def value(self, d, format='table'): return Printer.flatwrite( d, sort_keys=self.keys, order=self.order, header=self.header )
class Printer(object): def __init__(self, sort_keys=None, order=None, header=None): self.sort_keys = sort_keys self.order = order self.header = header def print(self, d, format='table'): print(self.value(d, format=format)) def value(self, d, format='table'): return Printer.flatwrite(d, sort_keys=self.keys, order=self.order, header=self.header)
# Copyright 2020 BlueCat Networks. All rights reserved. # -*- coding: utf-8 -*- type = 'api' sub_pages = [ { 'name' : 'user_inventory_page', 'title' : u'user_inventory', 'endpoint' : 'user_inventory/user_inventory_endpoint', 'description' : u'user_inventory' }, ]
type = 'api' sub_pages = [{'name': 'user_inventory_page', 'title': u'user_inventory', 'endpoint': 'user_inventory/user_inventory_endpoint', 'description': u'user_inventory'}]
__all__ = ("Values", ) class Data(object): def __init__( self, plugin_instance=None, meta=None, plugin=None, host=None, type=None, type_instance=None, interval=None, time=None, values=None, ): self.plugin = plugin self.plugin_instance = plugin_instance, self.meta = meta self.host = host self.type = type self.type_instance = type_instance self.dstypes = dstypes self.values = values self.interval = interval self.time = time def dispatch(self): pass def mk_values( plugin_instance=None, meta=None, plugin=None, host=None, type=None, type_instance=None, interval=None, time=None, values=None, ): return Data( plugin_instance=plugin_instance, meta=meta, plugin=plugin, host=host, type=type, type_instance=type_instance, interval=interval, time=time, values=values, ) Values = mk_values
__all__ = ('Values',) class Data(object): def __init__(self, plugin_instance=None, meta=None, plugin=None, host=None, type=None, type_instance=None, interval=None, time=None, values=None): self.plugin = plugin self.plugin_instance = (plugin_instance,) self.meta = meta self.host = host self.type = type self.type_instance = type_instance self.dstypes = dstypes self.values = values self.interval = interval self.time = time def dispatch(self): pass def mk_values(plugin_instance=None, meta=None, plugin=None, host=None, type=None, type_instance=None, interval=None, time=None, values=None): return data(plugin_instance=plugin_instance, meta=meta, plugin=plugin, host=host, type=type, type_instance=type_instance, interval=interval, time=time, values=values) values = mk_values
age = 6 if age < 1: print("baby") elif age < 3: print("toddler") elif age < 5: print("preschool") elif age < 12: print("gradeschooler") elif age < 19: print("teen") elif age > 20: print("old") else: print("integer error")
age = 6 if age < 1: print('baby') elif age < 3: print('toddler') elif age < 5: print('preschool') elif age < 12: print('gradeschooler') elif age < 19: print('teen') elif age > 20: print('old') else: print('integer error')
def main(): # input H, W = map(int, input().split()) sss = [input() for _ in range(H)] # compute cnt = 0 for h in range(1,H-1): for w in range(1,W-1): if sss[h][w]=='#' and sss[h-1][w]!='#' and sss[h+1][w]!='#' and sss[h][w-1]!='#' and sss[h][w+1]!='#': cnt += 1 # output if cnt == 0: print('Yes') else: print('No') if __name__ == '__main__': main()
def main(): (h, w) = map(int, input().split()) sss = [input() for _ in range(H)] cnt = 0 for h in range(1, H - 1): for w in range(1, W - 1): if sss[h][w] == '#' and sss[h - 1][w] != '#' and (sss[h + 1][w] != '#') and (sss[h][w - 1] != '#') and (sss[h][w + 1] != '#'): cnt += 1 if cnt == 0: print('Yes') else: print('No') if __name__ == '__main__': main()
class Solution: def getModifiedArray(self, length: int, updates: List[List[int]]) -> List[int]: arr = [0] * (length + 1) for s, e, i in updates: arr[s] += i arr[e+1] -= i for i in range(1, length): arr[i] += arr[i-1] return arr[:-1]
class Solution: def get_modified_array(self, length: int, updates: List[List[int]]) -> List[int]: arr = [0] * (length + 1) for (s, e, i) in updates: arr[s] += i arr[e + 1] -= i for i in range(1, length): arr[i] += arr[i - 1] return arr[:-1]
nerdle_len = 8 nerd_num_list = [str(x) for x in range(nerdle_len+2)] nerd_op_list = ['+','-','*','/','=='] nerd_list = nerd_num_list+nerd_op_list
nerdle_len = 8 nerd_num_list = [str(x) for x in range(nerdle_len + 2)] nerd_op_list = ['+', '-', '*', '/', '=='] nerd_list = nerd_num_list + nerd_op_list
''' As is can shift max '1111' -> 15 on one command... So a call like shift(20) would need to be split up... Thinking the user should do this when coding... or could be stdlib fx that does this... If want to do shift(16) in one cycle, can add s4 support (and correspoinding 16muxes) to hardware... revisit as needed ''' def shiftRight16_( x, y ): ''' 16 bit barrel shifter (right) ''' N = 16 t0 = [ None ] * N t1 = [ None ] * N t2 = [ None ] * N t3 = [ None ] * N y = y[::-1] # make life simpler by matching array access to MSB-to-LSB format # for i in range( N - 1, 0, -1 ): t0[i] = mux_( x[ i - 1 ], x[i], y[0] ) t0[0] = mux_( 0, x[0], y[0] ) # for i in range( N - 1, 1, -1 ): t1[i] = mux_( t0[ i - 2 ], t0[i], y[1] ) t1[1] = mux_( 0, t0[1], y[1] ) t1[0] = mux_( 0, t0[0], y[1] ) # for i in range( N - 1, 3, -1 ): t2[i] = mux_( t1[ i - 4 ], t1[i], y[2] ) t2[3] = mux_( 0, t1[3], y[2] ) t2[2] = mux_( 0, t1[2], y[2] ) t2[1] = mux_( 0, t1[1], y[2] ) t2[0] = mux_( 0, t1[0], y[2] ) # for i in range( N - 1, 7, -1 ): t3[i] = mux_( t2[ i - 8 ], t2[i], y[3] ) t3[7] = mux_( 0, t2[7], y[3] ) t3[6] = mux_( 0, t2[6], y[3] ) t3[5] = mux_( 0, t2[5], y[3] ) t3[4] = mux_( 0, t2[4], y[3] ) t3[3] = mux_( 0, t2[3], y[3] ) t3[2] = mux_( 0, t2[2], y[3] ) t3[1] = mux_( 0, t2[1], y[3] ) t3[0] = mux_( 0, t2[0], y[3] ) # return t3 def shiftLeft16_( x, y ): ''' 16 bit barrel shifter (left) ''' N = 16 t0 = [ None ] * N t1 = [ None ] * N t2 = [ None ] * N t3 = [ None ] * N y = y[::-1] # make life simpler by matching array access to MSB-to-LSB format # t0[N - 1] = mux_( 0, x[N - 1], y[0] ) for i in range( N - 2, -1, -1 ): t0[i] = mux_( x[ i + 1 ], x[i], y[0] ) # t1[ N - 1 ] = mux_( 0, t0[ N - 1 ], y[1] ) t1[ N - 2 ] = mux_( 0, t0[ N - 2 ], y[1] ) for i in range( N - 3, -1, -1 ): t1[i] = mux_( t0[ i + 2 ], t0[i], y[1] ) # t2[ N - 1 ] = mux_( 0, t1[ N - 1 ], y[2] ) t2[ N - 2 ] = mux_( 0, t1[ N - 2 ], y[2] ) t2[ N - 3 ] = mux_( 0, t1[ N - 3 ], y[2] ) t2[ N - 4 ] = mux_( 0, t1[ N - 4 ], y[2] ) for i in range( N - 5, -1, -1 ): t2[i] = mux_( t1[ i + 4 ], t1[i], y[2] ) # t3[ N - 1 ] = mux_( 0, t2[ N - 1 ], y[3] ) t3[ N - 2 ] = mux_( 0, t2[ N - 2 ], y[3] ) t3[ N - 3 ] = mux_( 0, t2[ N - 3 ], y[3] ) t3[ N - 4 ] = mux_( 0, t2[ N - 4 ], y[3] ) t3[ N - 5 ] = mux_( 0, t2[ N - 5 ], y[3] ) t3[ N - 6 ] = mux_( 0, t2[ N - 6 ], y[3] ) t3[ N - 7 ] = mux_( 0, t2[ N - 7 ], y[3] ) t3[ N - 8 ] = mux_( 0, t2[ N - 8 ], y[3] ) for i in range( N - 9, -1, -1 ): t3[i] = mux_( t2[ i + 8 ], t2[i], y[3] ) # return t3
""" As is can shift max '1111' -> 15 on one command... So a call like shift(20) would need to be split up... Thinking the user should do this when coding... or could be stdlib fx that does this... If want to do shift(16) in one cycle, can add s4 support (and correspoinding 16muxes) to hardware... revisit as needed """ def shift_right16_(x, y): """ 16 bit barrel shifter (right) """ n = 16 t0 = [None] * N t1 = [None] * N t2 = [None] * N t3 = [None] * N y = y[::-1] for i in range(N - 1, 0, -1): t0[i] = mux_(x[i - 1], x[i], y[0]) t0[0] = mux_(0, x[0], y[0]) for i in range(N - 1, 1, -1): t1[i] = mux_(t0[i - 2], t0[i], y[1]) t1[1] = mux_(0, t0[1], y[1]) t1[0] = mux_(0, t0[0], y[1]) for i in range(N - 1, 3, -1): t2[i] = mux_(t1[i - 4], t1[i], y[2]) t2[3] = mux_(0, t1[3], y[2]) t2[2] = mux_(0, t1[2], y[2]) t2[1] = mux_(0, t1[1], y[2]) t2[0] = mux_(0, t1[0], y[2]) for i in range(N - 1, 7, -1): t3[i] = mux_(t2[i - 8], t2[i], y[3]) t3[7] = mux_(0, t2[7], y[3]) t3[6] = mux_(0, t2[6], y[3]) t3[5] = mux_(0, t2[5], y[3]) t3[4] = mux_(0, t2[4], y[3]) t3[3] = mux_(0, t2[3], y[3]) t3[2] = mux_(0, t2[2], y[3]) t3[1] = mux_(0, t2[1], y[3]) t3[0] = mux_(0, t2[0], y[3]) return t3 def shift_left16_(x, y): """ 16 bit barrel shifter (left) """ n = 16 t0 = [None] * N t1 = [None] * N t2 = [None] * N t3 = [None] * N y = y[::-1] t0[N - 1] = mux_(0, x[N - 1], y[0]) for i in range(N - 2, -1, -1): t0[i] = mux_(x[i + 1], x[i], y[0]) t1[N - 1] = mux_(0, t0[N - 1], y[1]) t1[N - 2] = mux_(0, t0[N - 2], y[1]) for i in range(N - 3, -1, -1): t1[i] = mux_(t0[i + 2], t0[i], y[1]) t2[N - 1] = mux_(0, t1[N - 1], y[2]) t2[N - 2] = mux_(0, t1[N - 2], y[2]) t2[N - 3] = mux_(0, t1[N - 3], y[2]) t2[N - 4] = mux_(0, t1[N - 4], y[2]) for i in range(N - 5, -1, -1): t2[i] = mux_(t1[i + 4], t1[i], y[2]) t3[N - 1] = mux_(0, t2[N - 1], y[3]) t3[N - 2] = mux_(0, t2[N - 2], y[3]) t3[N - 3] = mux_(0, t2[N - 3], y[3]) t3[N - 4] = mux_(0, t2[N - 4], y[3]) t3[N - 5] = mux_(0, t2[N - 5], y[3]) t3[N - 6] = mux_(0, t2[N - 6], y[3]) t3[N - 7] = mux_(0, t2[N - 7], y[3]) t3[N - 8] = mux_(0, t2[N - 8], y[3]) for i in range(N - 9, -1, -1): t3[i] = mux_(t2[i + 8], t2[i], y[3]) return t3
# coding: utf-8 SECRET_KEY = 'foo' EMAIL_BACKEND = 'postmarker.django.EmailBackend' POSTMARK = { 'TOKEN': '<YOUR POSTMARK SERVER TOKEN>' }
secret_key = 'foo' email_backend = 'postmarker.django.EmailBackend' postmark = {'TOKEN': '<YOUR POSTMARK SERVER TOKEN>'}
def is_prime(num, primes): for prime in primes: if prime == num: return True if not num % prime: return False return True def get_primes(num): limit = (num // 2) + 1 candidates = list() primes = list() for i in range(2, limit): if is_prime(i, primes): primes.append(i) candidates.append((i, num - i)) new_candidates = list() for first, second in candidates[::-1]: if is_prime(second, primes): primes.append(second) new_candidates.append((first, second)) return new_candidates[-1] assert get_primes(4) == (2, 2) assert get_primes(10) == (3, 7) assert get_primes(100) == (3, 97)
def is_prime(num, primes): for prime in primes: if prime == num: return True if not num % prime: return False return True def get_primes(num): limit = num // 2 + 1 candidates = list() primes = list() for i in range(2, limit): if is_prime(i, primes): primes.append(i) candidates.append((i, num - i)) new_candidates = list() for (first, second) in candidates[::-1]: if is_prime(second, primes): primes.append(second) new_candidates.append((first, second)) return new_candidates[-1] assert get_primes(4) == (2, 2) assert get_primes(10) == (3, 7) assert get_primes(100) == (3, 97)
#program to remove two duplicate numbers from a given number of list. def two_unique_nums(nums): return [i for i in nums if nums.count(i)==1] print(two_unique_nums([1,2,3,2,3,4,5])) print(two_unique_nums([1,2,3,2,4,5])) print(two_unique_nums([1,2,3,4,5]))
def two_unique_nums(nums): return [i for i in nums if nums.count(i) == 1] print(two_unique_nums([1, 2, 3, 2, 3, 4, 5])) print(two_unique_nums([1, 2, 3, 2, 4, 5])) print(two_unique_nums([1, 2, 3, 4, 5]))
types = [ { 'name': 'RNAExpression', 'item_type': 'rna-expression', 'schema': { 'title': 'RNAExpression', 'description': 'Schema for RNA-seq expression', 'properties': { 'uuid': { 'title': 'UUID', }, 'expression': { 'type': 'object', 'properties': { 'gene_id': { 'title': 'Gene ID', 'type': 'string' }, 'transcript_ids': { 'title': 'Transcript ID', 'type': 'string' }, 'tpm': { 'title': 'TPM', 'type': 'float' }, 'fpkm': { 'title': 'FPKM', 'type': 'float' } } }, 'file': { 'type': 'object', 'properties': { '@id': { 'type': 'string' }, 'assay_title': { 'title': 'Assay title', 'type': 'string' }, 'assembly': { 'title': 'Assembly', 'type': 'string' }, 'biosample_ontology': { 'type': 'object', 'properties': { 'organ_slims': { 'type': 'string' }, 'term_name': { 'type': 'string' }, 'synonyms': { 'type': 'string' }, 'name': { 'type': 'string' }, 'term_id': { 'type': 'string' }, 'classification': { 'type': 'string' } } }, 'dataset': { 'type': 'string' }, 'donors': { 'type': 'string' }, 'genome_annotation': { 'type': 'string' } } }, 'dataset': { 'type': 'object', 'properties': { '@id': { 'type': 'string' }, 'biosample_summary': { 'type': 'string' }, 'replicates': { 'type': 'object', 'properties': { 'library': { 'type': 'object', 'properties': { 'biosample': { 'type': 'object', 'properties': { 'age_units': { 'type': 'string' }, 'sex': { 'type': 'string' }, 'age': { 'type': 'string' }, 'donor': { 'type': 'object', 'properties': { 'organism': { 'type': 'object', 'properties': { 'scientific_name': { 'type': 'string' } } } } } } } } } } } } }, 'gene': { 'type': 'object', 'properties': { 'geneid': { 'type': 'string' }, 'symbol': { 'type': 'string' }, 'name': { 'type': 'string' }, 'synonyms': { 'type': 'string' }, '@id': { 'type': 'string' }, 'title': { 'type': 'string' } } }, '@id': { 'title': 'ID', 'type': 'string', }, '@type': { 'title': 'Type', 'type': 'array', 'items': { 'type': 'string' }, } }, 'columns': { 'expression.gene_id': { 'title': 'Feature ID' }, 'expression.tpm': { 'title': 'TPM' }, 'expression.fpkm': { 'title': 'FPKM' }, 'gene.symbol': { 'title': 'Gene symbol' }, 'gene.name': { 'title': 'Gene name' }, 'gene.title': { 'title': 'Gene title' }, 'file.biosample_ontology.term_name': { 'title': 'Biosample term name' }, 'file.assay_title': { 'title': 'Assay title' }, 'file.assembly': { 'title': 'Assembly' }, 'file.biosample_ontology.classification': { 'title': 'Biosample classification' }, 'file.biosample_ontology.organ_slims': { 'title': 'Biosample organ' }, 'dataset.replicates.library.biosample.sex': { 'title': 'Biosample sex' }, 'dataset.replicates.library.biosample.donor.organism.scientific_name': { 'title': 'Organism' }, 'dataset.biosample_summary': { 'title': 'Biosample summary' }, 'file.genome_annotation': { 'title': 'Genome annotation' }, 'file.donors': { 'title': 'Donors' }, 'file.@id': { 'title': 'File' }, 'dataset.@id': { 'title': 'Experiment' } }, 'facets': { 'file.assay_title': { 'title': 'Assay title', 'open_on_load': True }, 'file.biosample_ontology.classification': { 'title': 'Biosample classification', 'open_on_load': True }, 'file.biosample_ontology.term_name': { 'title': 'Biosample term name', 'open_on_load': True, 'type': 'typeahead', 'length': 'long' }, 'file.assembly': { 'title': 'Assembly', 'open_on_load': True }, 'dataset.replicates.library.biosample.donor.organism.scientific_name': { 'title': 'Organism', 'open_on_load': True }, 'dataset.replicates.library.biosample.sex': { 'title': 'Biosample sex' } }, } } ]
types = [{'name': 'RNAExpression', 'item_type': 'rna-expression', 'schema': {'title': 'RNAExpression', 'description': 'Schema for RNA-seq expression', 'properties': {'uuid': {'title': 'UUID'}, 'expression': {'type': 'object', 'properties': {'gene_id': {'title': 'Gene ID', 'type': 'string'}, 'transcript_ids': {'title': 'Transcript ID', 'type': 'string'}, 'tpm': {'title': 'TPM', 'type': 'float'}, 'fpkm': {'title': 'FPKM', 'type': 'float'}}}, 'file': {'type': 'object', 'properties': {'@id': {'type': 'string'}, 'assay_title': {'title': 'Assay title', 'type': 'string'}, 'assembly': {'title': 'Assembly', 'type': 'string'}, 'biosample_ontology': {'type': 'object', 'properties': {'organ_slims': {'type': 'string'}, 'term_name': {'type': 'string'}, 'synonyms': {'type': 'string'}, 'name': {'type': 'string'}, 'term_id': {'type': 'string'}, 'classification': {'type': 'string'}}}, 'dataset': {'type': 'string'}, 'donors': {'type': 'string'}, 'genome_annotation': {'type': 'string'}}}, 'dataset': {'type': 'object', 'properties': {'@id': {'type': 'string'}, 'biosample_summary': {'type': 'string'}, 'replicates': {'type': 'object', 'properties': {'library': {'type': 'object', 'properties': {'biosample': {'type': 'object', 'properties': {'age_units': {'type': 'string'}, 'sex': {'type': 'string'}, 'age': {'type': 'string'}, 'donor': {'type': 'object', 'properties': {'organism': {'type': 'object', 'properties': {'scientific_name': {'type': 'string'}}}}}}}}}}}}}, 'gene': {'type': 'object', 'properties': {'geneid': {'type': 'string'}, 'symbol': {'type': 'string'}, 'name': {'type': 'string'}, 'synonyms': {'type': 'string'}, '@id': {'type': 'string'}, 'title': {'type': 'string'}}}, '@id': {'title': 'ID', 'type': 'string'}, '@type': {'title': 'Type', 'type': 'array', 'items': {'type': 'string'}}}, 'columns': {'expression.gene_id': {'title': 'Feature ID'}, 'expression.tpm': {'title': 'TPM'}, 'expression.fpkm': {'title': 'FPKM'}, 'gene.symbol': {'title': 'Gene symbol'}, 'gene.name': {'title': 'Gene name'}, 'gene.title': {'title': 'Gene title'}, 'file.biosample_ontology.term_name': {'title': 'Biosample term name'}, 'file.assay_title': {'title': 'Assay title'}, 'file.assembly': {'title': 'Assembly'}, 'file.biosample_ontology.classification': {'title': 'Biosample classification'}, 'file.biosample_ontology.organ_slims': {'title': 'Biosample organ'}, 'dataset.replicates.library.biosample.sex': {'title': 'Biosample sex'}, 'dataset.replicates.library.biosample.donor.organism.scientific_name': {'title': 'Organism'}, 'dataset.biosample_summary': {'title': 'Biosample summary'}, 'file.genome_annotation': {'title': 'Genome annotation'}, 'file.donors': {'title': 'Donors'}, 'file.@id': {'title': 'File'}, 'dataset.@id': {'title': 'Experiment'}}, 'facets': {'file.assay_title': {'title': 'Assay title', 'open_on_load': True}, 'file.biosample_ontology.classification': {'title': 'Biosample classification', 'open_on_load': True}, 'file.biosample_ontology.term_name': {'title': 'Biosample term name', 'open_on_load': True, 'type': 'typeahead', 'length': 'long'}, 'file.assembly': {'title': 'Assembly', 'open_on_load': True}, 'dataset.replicates.library.biosample.donor.organism.scientific_name': {'title': 'Organism', 'open_on_load': True}, 'dataset.replicates.library.biosample.sex': {'title': 'Biosample sex'}}}}]
def square(x): return x * x def launch_missiles(): print('missiles launched') def even_or_odd(n): if n % 2 == 0: print('even') return print('odd')
def square(x): return x * x def launch_missiles(): print('missiles launched') def even_or_odd(n): if n % 2 == 0: print('even') return print('odd')
n = 1 for i in range(1, 10 + 1): print(n) n *= i
n = 1 for i in range(1, 10 + 1): print(n) n *= i
#!/usr/bin/env python # coding: utf-8 # # Hill Cipher # Below is the code to implement the Hill Cipher, which is an example of a **polyalphabetic cryptosystem**, that is, it does # not assign a single ciphertext letter to a single plaintext letter, but rather a ciphertext letter may represent more than # one plaintext letter. This example is from Judson's [Abstract Algebra](http://abstract.ups.edu/sage-aata.html) textbook, # example 7.4. The encryption is based on the matrix # \begin{equation*} # A=\left(\begin{array}{cc} # 3 & 5 \\ # 1 & 2 # \end{array}\right) # \end{equation*} # and encryptes pairs of letters at a time, rather than one letter at a time. # # The digitize and alphabetize functions are rather similar to the ones found in the CeasarCipher document, the bigest change # being that these pair the numbers up so as to form matrices for encryption and decryption. # In[ ]: def digitize(string): cipher_text = [] holder = [] for i in string: if i == 'A' or i == 'a': holder.append(0) if i == 'B' or i == 'b': holder.append(1) if i == 'C' or i == 'c': holder.append(2) if i == 'D' or i == 'd': holder.append(3) if i == 'E' or i == 'e': holder.append(4) if i == 'F' or i == 'f': holder.append(5) if i == 'G' or i == 'g': holder.append(6) if i == 'H' or i == 'h': holder.append(7) if i == 'I' or i == 'i': holder.append(8) if i == 'J' or i == 'j': holder.append(9) if i == 'K' or i == 'k': holder.append(10) if i == 'L' or i == 'l': holder.append(11) if i == 'M' or i == 'm': holder.append(12) if i == 'N' or i == 'n': holder.append(13) if i == 'O' or i == 'o': holder.append(14) if i == 'P' or i == 'p': holder.append(15) if i == 'Q' or i == 'q': holder.append(16) if i == 'R' or i == 'r': holder.append(17) if i == 'S' or i == 's': holder.append(18) if i == 'T' or i == 't': holder.append(19) if i == 'U' or i == 'u': holder.append(20) if i == 'V' or i == 'v': holder.append(21) if i == 'W' or i == 'w': holder.append(22) if i == 'X' or i == 'x': holder.append(23) if i == 'Y' or i == 'y': holder.append(24) if i == 'Z' or i == 'z': holder.append(25) if len(holder)==2: cipher_text.append(matrix(holder)) holder = [] if len(holder)==1: holder.append(23) cipher_text.append(matrix(holder)) return cipher_text # In[ ]: def alphabetize(digits): plain_text = "" comparison = MatrixSpace(IntegerModRing(26),1,1) for number in digits: for i in number: if i == comparison([0])[0]: plain_text = plain_text + "A" if i == comparison([1])[0]: plain_text = plain_text + "B" if i == comparison([2])[0]: plain_text = plain_text + "C" if i == comparison([3])[0]: plain_text = plain_text + "D" if i == comparison([4])[0]: plain_text = plain_text + "E" if i == comparison([5])[0]: plain_text = plain_text + "F" if i == comparison([6])[0]: plain_text = plain_text + "G" if i == comparison([7])[0]: plain_text = plain_text + "H" if i == comparison([8])[0]: plain_text = plain_text + "I" if i == comparison([9])[0]: plain_text = plain_text + "J" if i == comparison([10])[0]: plain_text = plain_text + "K" if i == comparison([11])[0]: plain_text = plain_text + "L" if i == comparison([12])[0]: plain_text = plain_text + "M" if i == comparison([13])[0]: plain_text = plain_text + "N" if i == comparison([14])[0]: plain_text = plain_text + "O" if i == comparison([15])[0]: plain_text = plain_text + "P" if i == comparison([16])[0]: plain_text = plain_text + "Q" if i == comparison([17])[0]: plain_text = plain_text + "R" if i == comparison([18])[0]: plain_text = plain_text + "S" if i == comparison([19])[0]: plain_text = plain_text + "T" if i == comparison([20])[0]: plain_text = plain_text + "U" if i == comparison([21])[0]: plain_text = plain_text + "V" if i == comparison([22])[0]: plain_text = plain_text + "W" if i == comparison([23])[0]: plain_text = plain_text + "X" if i == comparison([24])[0]: plain_text = plain_text + "Y" if i == comparison([25])[0]: plain_text = plain_text + "Z" return plain_text # Here we define the HillEncrypt and HillDecrypt functions, which take in strings, and encrypt or decrypt them according # to the matrices passed into them as parameters. # In[ ]: def HillEncrypt(message, A, b): encoded = digitize(message) cipher_text = [] for item in encoded: cipher_text.append(A*item.transpose()+b) return alphabetize(cipher_text) def HillDecrypt(message, A, b): A = A.inverse() encoded = digitize(message) plain_text = [] for item in encoded: plain_text.append(A*item.transpose()-A*b) return alphabetize(plain_text) # Here we use MatrixSpaces over the Ring of integers mod 26, to define the matrices used for encryption and decryption. # We use MatrixSpaces rather than ordinary matrices to ensure that the inverse of $A$ is calculated correctly. # In[ ]: Z22_26 = MatrixSpace(IntegerModRing(26),2,2) Z21_26 = MatrixSpace(IntegerModRing(26),2,1) # these are the matrices used in the example in the book. A = Z22_26([[3,5],[1,2]]) b = Z21_26([2,2]) # Here we go through our first example, which is the example in the book, encrypting the message "help". # In[ ]: message = "help" encrypted = HillEncrypt(message,A,b) print(encrypted) decrypted = HillDecrypt(encrypted,A,b) print(decrypted)
def digitize(string): cipher_text = [] holder = [] for i in string: if i == 'A' or i == 'a': holder.append(0) if i == 'B' or i == 'b': holder.append(1) if i == 'C' or i == 'c': holder.append(2) if i == 'D' or i == 'd': holder.append(3) if i == 'E' or i == 'e': holder.append(4) if i == 'F' or i == 'f': holder.append(5) if i == 'G' or i == 'g': holder.append(6) if i == 'H' or i == 'h': holder.append(7) if i == 'I' or i == 'i': holder.append(8) if i == 'J' or i == 'j': holder.append(9) if i == 'K' or i == 'k': holder.append(10) if i == 'L' or i == 'l': holder.append(11) if i == 'M' or i == 'm': holder.append(12) if i == 'N' or i == 'n': holder.append(13) if i == 'O' or i == 'o': holder.append(14) if i == 'P' or i == 'p': holder.append(15) if i == 'Q' or i == 'q': holder.append(16) if i == 'R' or i == 'r': holder.append(17) if i == 'S' or i == 's': holder.append(18) if i == 'T' or i == 't': holder.append(19) if i == 'U' or i == 'u': holder.append(20) if i == 'V' or i == 'v': holder.append(21) if i == 'W' or i == 'w': holder.append(22) if i == 'X' or i == 'x': holder.append(23) if i == 'Y' or i == 'y': holder.append(24) if i == 'Z' or i == 'z': holder.append(25) if len(holder) == 2: cipher_text.append(matrix(holder)) holder = [] if len(holder) == 1: holder.append(23) cipher_text.append(matrix(holder)) return cipher_text def alphabetize(digits): plain_text = '' comparison = matrix_space(integer_mod_ring(26), 1, 1) for number in digits: for i in number: if i == comparison([0])[0]: plain_text = plain_text + 'A' if i == comparison([1])[0]: plain_text = plain_text + 'B' if i == comparison([2])[0]: plain_text = plain_text + 'C' if i == comparison([3])[0]: plain_text = plain_text + 'D' if i == comparison([4])[0]: plain_text = plain_text + 'E' if i == comparison([5])[0]: plain_text = plain_text + 'F' if i == comparison([6])[0]: plain_text = plain_text + 'G' if i == comparison([7])[0]: plain_text = plain_text + 'H' if i == comparison([8])[0]: plain_text = plain_text + 'I' if i == comparison([9])[0]: plain_text = plain_text + 'J' if i == comparison([10])[0]: plain_text = plain_text + 'K' if i == comparison([11])[0]: plain_text = plain_text + 'L' if i == comparison([12])[0]: plain_text = plain_text + 'M' if i == comparison([13])[0]: plain_text = plain_text + 'N' if i == comparison([14])[0]: plain_text = plain_text + 'O' if i == comparison([15])[0]: plain_text = plain_text + 'P' if i == comparison([16])[0]: plain_text = plain_text + 'Q' if i == comparison([17])[0]: plain_text = plain_text + 'R' if i == comparison([18])[0]: plain_text = plain_text + 'S' if i == comparison([19])[0]: plain_text = plain_text + 'T' if i == comparison([20])[0]: plain_text = plain_text + 'U' if i == comparison([21])[0]: plain_text = plain_text + 'V' if i == comparison([22])[0]: plain_text = plain_text + 'W' if i == comparison([23])[0]: plain_text = plain_text + 'X' if i == comparison([24])[0]: plain_text = plain_text + 'Y' if i == comparison([25])[0]: plain_text = plain_text + 'Z' return plain_text def hill_encrypt(message, A, b): encoded = digitize(message) cipher_text = [] for item in encoded: cipher_text.append(A * item.transpose() + b) return alphabetize(cipher_text) def hill_decrypt(message, A, b): a = A.inverse() encoded = digitize(message) plain_text = [] for item in encoded: plain_text.append(A * item.transpose() - A * b) return alphabetize(plain_text) z22_26 = matrix_space(integer_mod_ring(26), 2, 2) z21_26 = matrix_space(integer_mod_ring(26), 2, 1) a = z22_26([[3, 5], [1, 2]]) b = z21_26([2, 2]) message = 'help' encrypted = hill_encrypt(message, A, b) print(encrypted) decrypted = hill_decrypt(encrypted, A, b) print(decrypted)
file = open('Advent-of-Code-2021\\Day 13\\Day 13 input.txt') points = [] folds = [] for line in file: line = line.strip() if (line.find(',') != -1): pointparse = line.split(',') points.append([int(pointparse[0]),int(pointparse[1])]) elif (line.find('=') != -1): foldparse = line.split('=') folds.append([foldparse[0][len(foldparse[0])-1], int(foldparse[1])]) else: "Do nothing" for thisfold in folds: newpoints = [] for point in points: if (thisfold[0] == 'x'): if (point[0] > thisfold[1]): checkpoint = [thisfold[1]-(point[0]-thisfold[1]),point[1]] if (checkpoint not in newpoints): newpoints.append(checkpoint) elif (point not in newpoints): newpoints.append(point) else: "Do Nothing" else: if (point[1] > thisfold[1]): checkpoint = [point[0],thisfold[1]-(point[1]-thisfold[1])] if (checkpoint not in newpoints): newpoints.append(checkpoint) elif (point not in newpoints): newpoints.append(point) else: "Do Nothing" points = newpoints maxX = 0 maxY = 0 for point in points: if (point[0] > maxX): maxX = point[0] if (point[1] > maxY): maxY = point[1] outstring = [] for y in range(maxY+1): row = '' for x in range(maxX+1): if ([x,y] in points): row += '#' else: row += '.' outstring.append(row) for row in outstring: print(row)
file = open('Advent-of-Code-2021\\Day 13\\Day 13 input.txt') points = [] folds = [] for line in file: line = line.strip() if line.find(',') != -1: pointparse = line.split(',') points.append([int(pointparse[0]), int(pointparse[1])]) elif line.find('=') != -1: foldparse = line.split('=') folds.append([foldparse[0][len(foldparse[0]) - 1], int(foldparse[1])]) else: 'Do nothing' for thisfold in folds: newpoints = [] for point in points: if thisfold[0] == 'x': if point[0] > thisfold[1]: checkpoint = [thisfold[1] - (point[0] - thisfold[1]), point[1]] if checkpoint not in newpoints: newpoints.append(checkpoint) elif point not in newpoints: newpoints.append(point) else: 'Do Nothing' elif point[1] > thisfold[1]: checkpoint = [point[0], thisfold[1] - (point[1] - thisfold[1])] if checkpoint not in newpoints: newpoints.append(checkpoint) elif point not in newpoints: newpoints.append(point) else: 'Do Nothing' points = newpoints max_x = 0 max_y = 0 for point in points: if point[0] > maxX: max_x = point[0] if point[1] > maxY: max_y = point[1] outstring = [] for y in range(maxY + 1): row = '' for x in range(maxX + 1): if [x, y] in points: row += '#' else: row += '.' outstring.append(row) for row in outstring: print(row)
dummy1_iface_cfg = { 'INTERFACE': { 'MODULE': 'daq.interface.interface', 'CLASS': 'DummyInterface', }, 'IFCONFIG': { 'LABEL': 'Dummy1', 'ADDRESS': 'DummyAddress', 'SerialNumber': '1234', } } dummycpc_inst_cfg = { 'INSTRUMENT': { 'MODULE': 'daq.instrument.instrument', 'CLASS': 'DummyInstrument', }, 'INSTCONFIG': { 'DESCRIPTION': { 'LABEL': 'DummyCPC', 'SERIAL_NUMBER': '0001', 'PROPERTY_NUMBER': 'CD0000001', }, 'IFACE_LIST': { 'DUMMY1': { 'IFACE_CONFIG': dummy1_iface_cfg, 'OPERATION': { 'POLLED': False, 'SAMPLE_FREQ_SEC': 1, }, }, }, }, # could be IFACE_LIST to allow for multiple iface } dummy_controller_cfg = { 'CONTROLLER': { 'MODULE': 'daq.controller.controller', 'CLASS': 'Controller', } }
dummy1_iface_cfg = {'INTERFACE': {'MODULE': 'daq.interface.interface', 'CLASS': 'DummyInterface'}, 'IFCONFIG': {'LABEL': 'Dummy1', 'ADDRESS': 'DummyAddress', 'SerialNumber': '1234'}} dummycpc_inst_cfg = {'INSTRUMENT': {'MODULE': 'daq.instrument.instrument', 'CLASS': 'DummyInstrument'}, 'INSTCONFIG': {'DESCRIPTION': {'LABEL': 'DummyCPC', 'SERIAL_NUMBER': '0001', 'PROPERTY_NUMBER': 'CD0000001'}, 'IFACE_LIST': {'DUMMY1': {'IFACE_CONFIG': dummy1_iface_cfg, 'OPERATION': {'POLLED': False, 'SAMPLE_FREQ_SEC': 1}}}}} dummy_controller_cfg = {'CONTROLLER': {'MODULE': 'daq.controller.controller', 'CLASS': 'Controller'}}
print(dir(str)) nome = 'Flavio' print(nome) print(nome[:3]) texto = 'marca d\' agua' print(texto) texto = "marca d' agua" print(texto) texto = ''' texto ... texto ''' print(texto) texto = ' texto\n\t ...texto' print(texto) print(str.__add__('a', 'b')) nome = 'Flavio Garcia Fernandes' print(nome) print(nome[-9:]) print(nome[::-1]) numeros = '0123456789' print(numeros[1::2]) print(numeros[::2])
print(dir(str)) nome = 'Flavio' print(nome) print(nome[:3]) texto = "marca d' agua" print(texto) texto = "marca d' agua" print(texto) texto = ' texto\n ... texto\n' print(texto) texto = ' texto\n\t ...texto' print(texto) print(str.__add__('a', 'b')) nome = 'Flavio Garcia Fernandes' print(nome) print(nome[-9:]) print(nome[::-1]) numeros = '0123456789' print(numeros[1::2]) print(numeros[::2])
with open('in') as f: data = list(map(lambda l: list(l.strip().replace(' ', '')), f.readlines())) def evaluate(e): value = None operation = None i = 0 while i < len(e): c = e[i] if c in '+*': operation = c elif c in '0123456789': c = int(c) if operation is None: value = c else: if operation == '+': value += c else: value *= c elif c == '(': tmp_e = [] i += 1 level = 1 while True: if e[i] == '(': level += 1 elif e[i] == ')': level -= 1 if level == 0: break else: tmp_e.append(e[i]) i += 1 b = evaluate(tmp_e) if operation is None: value = b else: if operation == '+': value += b else: value *= b else: assert False i += 1 return value def evaluate_2(e): i = 0 while i < len(e): if e[i] == '+': level = 0 index = -1 for j in range(i - 1, -1, -1): if e[j] == ')': level += 1 elif e[j] == '(': level -= 1 if (level == 0 and e[j] in '+*') or (level < 0 and e[j] in '()'): index = j break e.insert(index + 1, '(') i += 1 level = 0 index = len(e) for j in range(i + 1, len(e)): if e[j] == '(': level += 1 elif e[j] == ')': level -= 1 if (level == 0 and e[j] in '+*') or (level < 0 and e[j] in '()'): index = j break e.insert(index, ')') i += 1 return evaluate(e) def part_one(): return sum(map(evaluate, data)) def part_two(): return sum(map(evaluate_2, data)) if __name__ == '__main__': print(f'Part One: {part_one()}') print(f'Part Two: {part_two()}')
with open('in') as f: data = list(map(lambda l: list(l.strip().replace(' ', '')), f.readlines())) def evaluate(e): value = None operation = None i = 0 while i < len(e): c = e[i] if c in '+*': operation = c elif c in '0123456789': c = int(c) if operation is None: value = c elif operation == '+': value += c else: value *= c elif c == '(': tmp_e = [] i += 1 level = 1 while True: if e[i] == '(': level += 1 elif e[i] == ')': level -= 1 if level == 0: break else: tmp_e.append(e[i]) i += 1 b = evaluate(tmp_e) if operation is None: value = b elif operation == '+': value += b else: value *= b else: assert False i += 1 return value def evaluate_2(e): i = 0 while i < len(e): if e[i] == '+': level = 0 index = -1 for j in range(i - 1, -1, -1): if e[j] == ')': level += 1 elif e[j] == '(': level -= 1 if level == 0 and e[j] in '+*' or (level < 0 and e[j] in '()'): index = j break e.insert(index + 1, '(') i += 1 level = 0 index = len(e) for j in range(i + 1, len(e)): if e[j] == '(': level += 1 elif e[j] == ')': level -= 1 if level == 0 and e[j] in '+*' or (level < 0 and e[j] in '()'): index = j break e.insert(index, ')') i += 1 return evaluate(e) def part_one(): return sum(map(evaluate, data)) def part_two(): return sum(map(evaluate_2, data)) if __name__ == '__main__': print(f'Part One: {part_one()}') print(f'Part Two: {part_two()}')
# just keep this as-is def not_an_activity(): print("boom")
def not_an_activity(): print('boom')
label_data = open("label", encoding='utf-8').readlines() label_data = [x.strip() for x in label_data] print(len(label_data)) label_kinds = set(label_data) print(label_kinds)
label_data = open('label', encoding='utf-8').readlines() label_data = [x.strip() for x in label_data] print(len(label_data)) label_kinds = set(label_data) print(label_kinds)
def tupler(atuple): print(f"{atuple=}") return (1, 2, 3) print(f"{type(tupler((10, 11)))=}")
def tupler(atuple): print(f'atuple={atuple!r}') return (1, 2, 3) print(f'type(tupler((10, 11)))={type(tupler((10, 11)))!r}')
n1 = int (input()) s1 = set(map(int,input().split())) n2 = int (input()) s2 = set(map(int,input().split())) print(len(s1.intersection(s2)))
n1 = int(input()) s1 = set(map(int, input().split())) n2 = int(input()) s2 = set(map(int, input().split())) print(len(s1.intersection(s2)))
raio = int(input()) pi = 3.14159 volume = float(4.0 * pi * (raio* raio * raio) / 3) print("VOLUME = %0.3f" %volume)
raio = int(input()) pi = 3.14159 volume = float(4.0 * pi * (raio * raio * raio) / 3) print('VOLUME = %0.3f' % volume)
#!/usr/bin/env python # encoding: utf-8 GRADES_FILENAME = 'grades.csv' GRADING_SLASH_DELIMINATOR = '/' SUBMISSIONS_FILENAME = 'Submissions' GRADING_URL_EXTENSION = '&action=grading' SUBMISSION_LISTING_DELIMINATOR = '-_submission_-' GRADING_BLANK_GRADE = '-' GRADING_HEADER_NAME = 'Name' GRADING_HEADER_EMAIL = 'Email' GRADING_HEADER_GRADE = 'Grade'
grades_filename = 'grades.csv' grading_slash_deliminator = '/' submissions_filename = 'Submissions' grading_url_extension = '&action=grading' submission_listing_deliminator = '-_submission_-' grading_blank_grade = '-' grading_header_name = 'Name' grading_header_email = 'Email' grading_header_grade = 'Grade'
# IP and port to bind to. bind = ['127.0.0.1:4000'] # Maximum number of pending connections. backlog = 2048 # Number of worker processes to handle connections. workers = 2 # Fork main process to background. daemon = True # PID file to write to. pidfile = "web.gunicorn.pid" # Allow connections from any frontend proxy. # forwarded_allow_ips = '*' # Logging configuration. accesslog = "web.gunicorn.access.log" errorlog = "web.gunicorn.error.log" loglevel = "warning" # Gunicorn process name. proc_name = "rouly.net-gunicorn"
bind = ['127.0.0.1:4000'] backlog = 2048 workers = 2 daemon = True pidfile = 'web.gunicorn.pid' accesslog = 'web.gunicorn.access.log' errorlog = 'web.gunicorn.error.log' loglevel = 'warning' proc_name = 'rouly.net-gunicorn'
i = 0 while(True): if i+1<5: i = i + 1 continue print(i+1, end=" ") if(i==50): break #stop the loop i = i+ 1
i = 0 while True: if i + 1 < 5: i = i + 1 continue print(i + 1, end=' ') if i == 50: break i = i + 1
#https://leetcode.com/problems/min-stack/ class MinStack(object): def __init__(self): self.stack = [] def push(self, x): self.stack.append((x, min(x, self.getMin()))) def pop(self): if len(self.stack)==0: return None return self.stack.pop()[0] def top(self): if len(self.stack)==0: return None return self.stack[-1][0] def getMin(self): if len(self.stack)==0: return float('inf') return self.stack[-1][1] # Your MinStack object will be instantiated and called as such: # obj = MinStack() # obj.push(x) # obj.pop() # param_3 = obj.top() # param_4 = obj.getMin()
class Minstack(object): def __init__(self): self.stack = [] def push(self, x): self.stack.append((x, min(x, self.getMin()))) def pop(self): if len(self.stack) == 0: return None return self.stack.pop()[0] def top(self): if len(self.stack) == 0: return None return self.stack[-1][0] def get_min(self): if len(self.stack) == 0: return float('inf') return self.stack[-1][1]
def insert_newlines(string, every=64): return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) for __ in range(int(input())): n = int(input()) o = "O" x = "X" a = ["X" for i in range(64)] for i in range(n): a[i] = "." a[0]=o print(insert_newlines("".join(a),8))
def insert_newlines(string, every=64): return '\n'.join((string[i:i + every] for i in range(0, len(string), every))) for __ in range(int(input())): n = int(input()) o = 'O' x = 'X' a = ['X' for i in range(64)] for i in range(n): a[i] = '.' a[0] = o print(insert_newlines(''.join(a), 8))
## Set Configs print('Set configs..') sns.set() pd.options.display.max_columns = None RANDOM_SEED = 42 fig_path = os.path.join(os.getcwd(), 'figs') model_path = os.path.join(os.getcwd(), 'models') model_bib_path = os.path.join(model_path,'model_bib') data_path = os.path.join(os.getcwd(), 'data') ## read the data print('Read the data..') data_fn = os.path.join(data_path, 'simulation_data_y_2020_2021_reduced.h5') df_data = pd.read_hdf(data_fn, key='df') print('Shape of normal data (X_sim): {}'.format(df_data.shape)) data_fn_anormal = os.path.join(data_path, 'anomalous_data_y_2022_reduced.h5') df_data_anormal = pd.read_hdf(data_fn_anormal, key='df') print('Shape of anormal data (X_test): {}'.format(df_data_anormal.shape)) data_fn_drifted = os.path.join(data_path, 'drifted_data_y_2023_reduced_more_cos_phi.h5') df_data_drifted = pd.read_hdf(data_fn_drifted, key='df') print('Shape of drifted data (X_drifted): {}'.format(df_data_drifted.shape)) data_fn_drifted_anormal = os.path.join(data_path, 'anomalous_drifted_data_y_2023_reduced_more_cos_phi.h5') df_data_drifted_anormal = pd.read_hdf(data_fn_drifted_anormal, key='df') print('Shape of drifted anormal data (X_drifted,anormal): {}'.format(df_data_drifted_anormal.shape)) ## save label print('Save label..') s_labels = df_data_anormal['label'] df_data_anormal.drop('label', axis=1, inplace=True) print('Shape of anormal data (X_test): {}'.format(df_data_anormal.shape)) s_drift_labels = df_data_drifted['drift_labels'] df_data_drifted.drop('drift_labels',axis=1,inplace=True) print('Shape of drifted data (X_drifted): {}'.format(df_data_drifted.shape)) s_drift_labels_drifted_ano = df_data_drifted_anormal['drift_labels'] df_data_drifted_anormal.drop('drift_labels', axis=1, inplace=True) s_ano_labels_drifted_ano = df_data_drifted_anormal['anomaly_labels'] df_data_drifted_anormal.drop('anomaly_labels', axis=1, inplace=True) print('Shape of drifted anormal data (X_drifted,anormal): {}'.format(df_data_drifted_anormal.shape)) ### Scale data print('Scale data..') scaler_train = MinMaxScaler((-1,1)) scaler_train = scaler_train.fit(df_data) scaled_anormal = scaler_train.transform(df_data_anormal.to_numpy()) scaled_normal = scaler_train.transform(df_data.to_numpy()) scaled_drifted = scaler_train.transform(df_data_drifted.to_numpy()) scaled_drifted_anormal = scaler_train.transform(df_data_drifted_anormal.to_numpy()) ## prepare for PyTorch print('Prepare data for PyTorch..') # build tensor from numpy anormal_torch_tensor = torch.from_numpy(scaled_anormal).type(torch.FloatTensor) normal_torch_tensor = torch.from_numpy(scaled_normal).type(torch.FloatTensor) drifted_torch_tensor = torch.from_numpy(scaled_drifted).type(torch.FloatTensor) drifted_anormal_torch_tensor = torch.from_numpy(scaled_drifted_anormal).type(torch.FloatTensor) # build TensorDataset from Tensor anormal_dataset = TensorDataset(anormal_torch_tensor, anormal_torch_tensor) normal_dataset = TensorDataset(normal_torch_tensor, normal_torch_tensor) drifted_dataset = TensorDataset(drifted_torch_tensor, drifted_torch_tensor) drifted_anormal_dataset = TensorDataset(drifted_anormal_torch_tensor, drifted_anormal_torch_tensor) # build DataLoader from TensorDataset anormal_dataloader = torch.utils.data.DataLoader(anormal_dataset,batch_size=128,shuffle=False, num_workers=0) normal_dataloader = torch.utils.data.DataLoader(normal_dataset,batch_size=128,shuffle=False, num_workers=0) drifted_dataloader = torch.utils.data.DataLoader(drifted_dataset,batch_size=128,shuffle=False, num_workers=0) drifted_anormal_dataloader = torch.utils.data.DataLoader(drifted_anormal_dataset, batch_size=128, shuffle=False, num_workers=0)
print('Set configs..') sns.set() pd.options.display.max_columns = None random_seed = 42 fig_path = os.path.join(os.getcwd(), 'figs') model_path = os.path.join(os.getcwd(), 'models') model_bib_path = os.path.join(model_path, 'model_bib') data_path = os.path.join(os.getcwd(), 'data') print('Read the data..') data_fn = os.path.join(data_path, 'simulation_data_y_2020_2021_reduced.h5') df_data = pd.read_hdf(data_fn, key='df') print('Shape of normal data (X_sim): {}'.format(df_data.shape)) data_fn_anormal = os.path.join(data_path, 'anomalous_data_y_2022_reduced.h5') df_data_anormal = pd.read_hdf(data_fn_anormal, key='df') print('Shape of anormal data (X_test): {}'.format(df_data_anormal.shape)) data_fn_drifted = os.path.join(data_path, 'drifted_data_y_2023_reduced_more_cos_phi.h5') df_data_drifted = pd.read_hdf(data_fn_drifted, key='df') print('Shape of drifted data (X_drifted): {}'.format(df_data_drifted.shape)) data_fn_drifted_anormal = os.path.join(data_path, 'anomalous_drifted_data_y_2023_reduced_more_cos_phi.h5') df_data_drifted_anormal = pd.read_hdf(data_fn_drifted_anormal, key='df') print('Shape of drifted anormal data (X_drifted,anormal): {}'.format(df_data_drifted_anormal.shape)) print('Save label..') s_labels = df_data_anormal['label'] df_data_anormal.drop('label', axis=1, inplace=True) print('Shape of anormal data (X_test): {}'.format(df_data_anormal.shape)) s_drift_labels = df_data_drifted['drift_labels'] df_data_drifted.drop('drift_labels', axis=1, inplace=True) print('Shape of drifted data (X_drifted): {}'.format(df_data_drifted.shape)) s_drift_labels_drifted_ano = df_data_drifted_anormal['drift_labels'] df_data_drifted_anormal.drop('drift_labels', axis=1, inplace=True) s_ano_labels_drifted_ano = df_data_drifted_anormal['anomaly_labels'] df_data_drifted_anormal.drop('anomaly_labels', axis=1, inplace=True) print('Shape of drifted anormal data (X_drifted,anormal): {}'.format(df_data_drifted_anormal.shape)) print('Scale data..') scaler_train = min_max_scaler((-1, 1)) scaler_train = scaler_train.fit(df_data) scaled_anormal = scaler_train.transform(df_data_anormal.to_numpy()) scaled_normal = scaler_train.transform(df_data.to_numpy()) scaled_drifted = scaler_train.transform(df_data_drifted.to_numpy()) scaled_drifted_anormal = scaler_train.transform(df_data_drifted_anormal.to_numpy()) print('Prepare data for PyTorch..') anormal_torch_tensor = torch.from_numpy(scaled_anormal).type(torch.FloatTensor) normal_torch_tensor = torch.from_numpy(scaled_normal).type(torch.FloatTensor) drifted_torch_tensor = torch.from_numpy(scaled_drifted).type(torch.FloatTensor) drifted_anormal_torch_tensor = torch.from_numpy(scaled_drifted_anormal).type(torch.FloatTensor) anormal_dataset = tensor_dataset(anormal_torch_tensor, anormal_torch_tensor) normal_dataset = tensor_dataset(normal_torch_tensor, normal_torch_tensor) drifted_dataset = tensor_dataset(drifted_torch_tensor, drifted_torch_tensor) drifted_anormal_dataset = tensor_dataset(drifted_anormal_torch_tensor, drifted_anormal_torch_tensor) anormal_dataloader = torch.utils.data.DataLoader(anormal_dataset, batch_size=128, shuffle=False, num_workers=0) normal_dataloader = torch.utils.data.DataLoader(normal_dataset, batch_size=128, shuffle=False, num_workers=0) drifted_dataloader = torch.utils.data.DataLoader(drifted_dataset, batch_size=128, shuffle=False, num_workers=0) drifted_anormal_dataloader = torch.utils.data.DataLoader(drifted_anormal_dataset, batch_size=128, shuffle=False, num_workers=0)
a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] # dumb way # for i in range(0,len(a),1): # if a[i]%2 == 0: # print(str(a[i]),end=" ") b = [i for i in a if i % 2 == 0] print(b)
a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] b = [i for i in a if i % 2 == 0] print(b)
''' Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two one's added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II. Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used: I can be placed before V (5) and X (10) to make 4 and 9. X can be placed before L (50) and C (100) to make 40 and 90. C can be placed before D (500) and M (1000) to make 400 and 900. Given a roman numeral, convert it to an integer. ''' class Solution: def romanToInt(self, s: str) -> int: roman = {'I' : 1, 'V' : 5, 'X' : 10, 'L' : 50, 'C' : 100, 'D' : 500, 'M' : 1000 } ans = 0 for i in range(len(s)): if i < len(s) - 1 and roman[s[i]] < roman[s[i + 1]]: ans -= roman[s[i]] else: ans += roman[s[i]] return ans
""" Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two one's added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II. Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used: I can be placed before V (5) and X (10) to make 4 and 9. X can be placed before L (50) and C (100) to make 40 and 90. C can be placed before D (500) and M (1000) to make 400 and 900. Given a roman numeral, convert it to an integer. """ class Solution: def roman_to_int(self, s: str) -> int: roman = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} ans = 0 for i in range(len(s)): if i < len(s) - 1 and roman[s[i]] < roman[s[i + 1]]: ans -= roman[s[i]] else: ans += roman[s[i]] return ans
# https://www.codewars.com/kata/55a243393fb3e87021000198/train/python # My solution def remember(text): counter = {} result = [] for ch in text: counter[ch] = counter.get(ch, 0) + 1 if counter[ch] == 2: result.append(ch) return result # ... def remember(str_): seen = set() res = [] for i in str_: res.append(i) if i in seen and i not in res else seen.add(i) return res
def remember(text): counter = {} result = [] for ch in text: counter[ch] = counter.get(ch, 0) + 1 if counter[ch] == 2: result.append(ch) return result def remember(str_): seen = set() res = [] for i in str_: res.append(i) if i in seen and i not in res else seen.add(i) return res
directory_map = { "abilene": "directed-abilene-zhang-5min-over-6months-ALL", "geant": "directed-geant-uhlig-15min-over-4months-ALL", "germany50": "directed-germany50-DFN-aggregated-1day-over-1month", }
directory_map = {'abilene': 'directed-abilene-zhang-5min-over-6months-ALL', 'geant': 'directed-geant-uhlig-15min-over-4months-ALL', 'germany50': 'directed-germany50-DFN-aggregated-1day-over-1month'}
class Math1(): def __init__(self): self.my_num1 = 10 self.my_num2 = 20 def addition(self): return self.my_num1 + self.my_num2 def subtraction(self): return self.my_num1 - self.my_num2 class Math_Plus(Math1): def __init__(self, my_num1=40, my_num2=90): self.my_num1 = my_num1 self.my_num2 = my_num2 def multiplication(self): return self.my_num1 * self.my_num2 def division(self): return self.my_num1 / self.my_num2 if __name__ == "__main__": math1 = Math1() print(math1.addition()) #30 print(math1.subtraction()) #-10 math_plus = Math_Plus() print(math_plus.addition()) #130 print(math_plus.subtraction()) #-50 print(math_plus.multiplication()) #3600 print(math_plus.division()) #0.-44444444
class Math1: def __init__(self): self.my_num1 = 10 self.my_num2 = 20 def addition(self): return self.my_num1 + self.my_num2 def subtraction(self): return self.my_num1 - self.my_num2 class Math_Plus(Math1): def __init__(self, my_num1=40, my_num2=90): self.my_num1 = my_num1 self.my_num2 = my_num2 def multiplication(self): return self.my_num1 * self.my_num2 def division(self): return self.my_num1 / self.my_num2 if __name__ == '__main__': math1 = math1() print(math1.addition()) print(math1.subtraction()) math_plus = math__plus() print(math_plus.addition()) print(math_plus.subtraction()) print(math_plus.multiplication()) print(math_plus.division())
# single source of truth for package version, # see https://packaging.python.org/en/latest/single_source_version/ __version__ = "0.6.0" # app name to send as part of SDK requests app_name = "DLHub CLI v{}".format(__version__)
__version__ = '0.6.0' app_name = 'DLHub CLI v{}'.format(__version__)
# coding: utf8 # try something like def index(): return plugin_flatpage() def rfp(): return plugin_flatpage()
def index(): return plugin_flatpage() def rfp(): return plugin_flatpage()
''' PyTorch implementation of the RetinaNet object detector: Lin, Tsung-Yi, et al. "Focal loss for dense object detection." Proceedings of the IEEE international conference on computer vision. 2017. Basic implementation forked and adapted from: https://github.com/kuangliu/pytorch-retinanet 2019 Benjamin Kellenberger ''' # default options for the model, may be overridden in the custom configuration loaded at runtime DEFAULT_OPTIONS = { "general": { "image_size": [800, 600], "device": "cuda", "seed": 1234 }, "model": { "kwargs": { "backbone": "resnet50", "pretrained": False, "out_planes": 256, "convertToInstanceNorm": False } }, "train": { "dataLoader": { "kwargs": { "shuffle": True, "batch_size": 32 } }, "optim": { "class": "torch.optim.Adam", "kwargs": { "lr": 1e-7, "weight_decay": 0.0 } }, "transform": { "class": "ai.models.pytorch.boundingBoxes.Compose", "kwargs": { "transforms": [{ "class": "ai.models.pytorch.boundingBoxes.Resize", "kwargs": { "size": [800, 600] } }, { "class": "ai.models.pytorch.boundingBoxes.RandomHorizontalFlip", "kwargs": { "p": 0.5 } }, { "class": "ai.models.pytorch.boundingBoxes.DefaultTransform", "kwargs": { "transform": { "class": "torchvision.transforms.ColorJitter", "kwargs": { "brightness": 0.25, "contrast": 0.25, "saturation": 0.25, "hue": 0.01 } } } }, { "class": "ai.models.pytorch.boundingBoxes.DefaultTransform", "kwargs": { "transform": { "class": "torchvision.transforms.ToTensor" } } }, { "class": "ai.models.pytorch.boundingBoxes.DefaultTransform", "kwargs": { "transform": { "class": "torchvision.transforms.Normalize", "kwargs": { "mean": [0.485, 0.456, 0.406], "std": [0.229, 0.224, 0.225] } } } } ] } }, "criterion": { "class": "ai.models.pytorch.functional._retinanet.loss.FocalLoss", "kwargs": { "gamma": 2.0, "alpha": 0.25, "background_weight": 1.0 } }, "ignore_unsure": True }, "inference": { "transform": { "class": "ai.models.pytorch.boundingBoxes.Compose", "kwargs": { "transforms": [{ "class": "ai.models.pytorch.boundingBoxes.Resize", "kwargs": { "size": [800, 600] } }, { "class": "ai.models.pytorch.boundingBoxes.DefaultTransform", "kwargs": { "transform": { "class": "torchvision.transforms.ToTensor" } } }, { "class": "ai.models.pytorch.boundingBoxes.DefaultTransform", "kwargs": { "transform": { "class": "torchvision.transforms.Normalize", "kwargs": { "mean": [0.485, 0.456, 0.406], "std": [0.229, 0.224, 0.225] } } } } ] } }, "dataLoader": { "kwargs": { "shuffle": False, "batch_size": 32 } } } }
""" PyTorch implementation of the RetinaNet object detector: Lin, Tsung-Yi, et al. "Focal loss for dense object detection." Proceedings of the IEEE international conference on computer vision. 2017. Basic implementation forked and adapted from: https://github.com/kuangliu/pytorch-retinanet 2019 Benjamin Kellenberger """ default_options = {'general': {'image_size': [800, 600], 'device': 'cuda', 'seed': 1234}, 'model': {'kwargs': {'backbone': 'resnet50', 'pretrained': False, 'out_planes': 256, 'convertToInstanceNorm': False}}, 'train': {'dataLoader': {'kwargs': {'shuffle': True, 'batch_size': 32}}, 'optim': {'class': 'torch.optim.Adam', 'kwargs': {'lr': 1e-07, 'weight_decay': 0.0}}, 'transform': {'class': 'ai.models.pytorch.boundingBoxes.Compose', 'kwargs': {'transforms': [{'class': 'ai.models.pytorch.boundingBoxes.Resize', 'kwargs': {'size': [800, 600]}}, {'class': 'ai.models.pytorch.boundingBoxes.RandomHorizontalFlip', 'kwargs': {'p': 0.5}}, {'class': 'ai.models.pytorch.boundingBoxes.DefaultTransform', 'kwargs': {'transform': {'class': 'torchvision.transforms.ColorJitter', 'kwargs': {'brightness': 0.25, 'contrast': 0.25, 'saturation': 0.25, 'hue': 0.01}}}}, {'class': 'ai.models.pytorch.boundingBoxes.DefaultTransform', 'kwargs': {'transform': {'class': 'torchvision.transforms.ToTensor'}}}, {'class': 'ai.models.pytorch.boundingBoxes.DefaultTransform', 'kwargs': {'transform': {'class': 'torchvision.transforms.Normalize', 'kwargs': {'mean': [0.485, 0.456, 0.406], 'std': [0.229, 0.224, 0.225]}}}}]}}, 'criterion': {'class': 'ai.models.pytorch.functional._retinanet.loss.FocalLoss', 'kwargs': {'gamma': 2.0, 'alpha': 0.25, 'background_weight': 1.0}}, 'ignore_unsure': True}, 'inference': {'transform': {'class': 'ai.models.pytorch.boundingBoxes.Compose', 'kwargs': {'transforms': [{'class': 'ai.models.pytorch.boundingBoxes.Resize', 'kwargs': {'size': [800, 600]}}, {'class': 'ai.models.pytorch.boundingBoxes.DefaultTransform', 'kwargs': {'transform': {'class': 'torchvision.transforms.ToTensor'}}}, {'class': 'ai.models.pytorch.boundingBoxes.DefaultTransform', 'kwargs': {'transform': {'class': 'torchvision.transforms.Normalize', 'kwargs': {'mean': [0.485, 0.456, 0.406], 'std': [0.229, 0.224, 0.225]}}}}]}}, 'dataLoader': {'kwargs': {'shuffle': False, 'batch_size': 32}}}}
#import gui.gui as gui # Python3 program to find number # of bins required using # First Fit algorithm. # Returns number of bins required # using first fit # online algorithm def firstFit(weight, n, c): # Initialize result (Count of bins) res = 0 # Create an array to store # remaining space in bins # there can be at most n bins bin_rem = [0]*n # Place items one by one for i in range(n): # Find the first bin that # can accommodate # weight[i] j = 0 # Initialize minimum space # left and index # of best bin min = c + 1 bi = 0 for j in range(res): if (bin_rem[j] >= weight[i] and bin_rem[j] - weight[i] < min): bi = j min = bin_rem[j] - weight[i] # If no bin could accommodate weight[i], # create a new bin if (min == c + 1): bin_rem[res] = c - weight[i] res += 1 else: # Assign the item to best bin bin_rem[bi] -= weight[i] return res # Driver code if __name__ == '__main__': weight = [ 10, 5, 10, 7, 1, 10, 10 ] c = 10 n = len(weight) print("Number of bins required in First Fit : ", firstFit(weight, n, c))
def first_fit(weight, n, c): res = 0 bin_rem = [0] * n for i in range(n): j = 0 min = c + 1 bi = 0 for j in range(res): if bin_rem[j] >= weight[i] and bin_rem[j] - weight[i] < min: bi = j min = bin_rem[j] - weight[i] if min == c + 1: bin_rem[res] = c - weight[i] res += 1 else: bin_rem[bi] -= weight[i] return res if __name__ == '__main__': weight = [10, 5, 10, 7, 1, 10, 10] c = 10 n = len(weight) print('Number of bins required in First Fit : ', first_fit(weight, n, c))
# mapping for AWS IAM user_name to slack ID accross all AWS accounts # # Fill in "<aws_IAM_user_id>:<slack_id>" here. Seperate each entry by a comma, and leave the last one without a comma # Example: # mapping = { # "IAM_user_id1":"slack_id1", # "IAM_user_id2":"slack_id2", # "IAM_user_id3":"slack_id3" # } mapping = { "IAM_user_id1":"slack_id1", "IAM_user_id2":"slack_id2", "IAM_user_id3":"slack_id3" }
mapping = {'IAM_user_id1': 'slack_id1', 'IAM_user_id2': 'slack_id2', 'IAM_user_id3': 'slack_id3'}
# Bot's version number __version__ = "0.1.0" # Authorized guild GUILD_ID = 952941520867196958
__version__ = '0.1.0' guild_id = 952941520867196958
#Rep of loops numbers = [2, 3, 4, 45] l = len(numbers) for i in range(l): print(numbers[i]) # each iteration the i takes on a different #value according to len of numbers (4) for i in range(8): print(i) # prints numbers 0 through 7 for el in numbers: print(el) # using a loop to change elements within a list items = ['yellow', 'red', 'green', 'purple', 'blue'] #list of colours for i in range(5): print('Before item ', i , 'is', items[i]) items[i] = 'different' print('After item ', i , 'is', items[i]) items = ['yellow', 'red', 'green', 'purple', 'blue'] #list of colours for index_of_enumerate, colors in enumerate(items): print(index_of_enumerate, colors) # while: months = ['june', 'august', 'july', 'may'] i = 0 month = 'a' while month != 'august': month = months[i] print(month) i += 1 # Write your code below and press Shift+Enter to execute # Write a while loop to display the values of the Rating of an album playlist stored in the list PlayListRatings. If the score is less than 6, exit the loop. The list PlayListRatings is given by: PlayListRatings = [10, 9.5, 10, 8, 7.5, 5, 10, 10] PlayListRatings = [10, 9.5, 10, 8, 7.5, 5, 10, 10] i = 0 score = PlayListRatings[i] #print(score) while score >= 6: score = PlayListRatings[i] print(score) i += 1
numbers = [2, 3, 4, 45] l = len(numbers) for i in range(l): print(numbers[i]) for i in range(8): print(i) for el in numbers: print(el) items = ['yellow', 'red', 'green', 'purple', 'blue'] for i in range(5): print('Before item ', i, 'is', items[i]) items[i] = 'different' print('After item ', i, 'is', items[i]) items = ['yellow', 'red', 'green', 'purple', 'blue'] for (index_of_enumerate, colors) in enumerate(items): print(index_of_enumerate, colors) months = ['june', 'august', 'july', 'may'] i = 0 month = 'a' while month != 'august': month = months[i] print(month) i += 1 play_list_ratings = [10, 9.5, 10, 8, 7.5, 5, 10, 10] i = 0 score = PlayListRatings[i] while score >= 6: score = PlayListRatings[i] print(score) i += 1
def append_text(new_text): ''' Write the code instruction to be exported later on Args. new_text (str): the text that will be appended to the base string ''' global code_base_text code_base_text = code_base_text + new_text
def append_text(new_text): """ Write the code instruction to be exported later on Args. new_text (str): the text that will be appended to the base string """ global code_base_text code_base_text = code_base_text + new_text
n=int(input ('veverite')) if n %2==0: print ('par') else: print ('impar') print('par' if n%2==0 else 'impar')
n = int(input('veverite')) if n % 2 == 0: print('par') else: print('impar') print('par' if n % 2 == 0 else 'impar')
# pylint: disable=missing-class-docstring, disable=missing-function-docstring, missing-module-docstring/ #$ header class Point(public) #$ header method __init__(Point, double, double) #$ header method __del__(Point) #$ header method translate(Point, double, double) class Point(object): def __init__(self, x, y): self.x = x self.y = y def __del__(self): pass def translate(self, a, b): self.x = self.x + a self.y = self.y + b if __name__ == '__main__': p = Point(0.0, 0.0) x=p.x p.x=x a = p.x a = p.x - 2 a = 2 * p.x - 2 a = 2 * (p.x + 6) - 2 p.y = a + 5 p.y = p.x + 5 p.translate(1.0, 2.0) print(p.x, p.y) print(a) del p
class Point(object): def __init__(self, x, y): self.x = x self.y = y def __del__(self): pass def translate(self, a, b): self.x = self.x + a self.y = self.y + b if __name__ == '__main__': p = point(0.0, 0.0) x = p.x p.x = x a = p.x a = p.x - 2 a = 2 * p.x - 2 a = 2 * (p.x + 6) - 2 p.y = a + 5 p.y = p.x + 5 p.translate(1.0, 2.0) print(p.x, p.y) print(a) del p
# parsetab.py # This file is automatically generated. Do not edit. # pylint: disable=W,C,R _tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'leftPLUSMINUSleftTIMESDIVIDEleftPOWERrightUMINUSCOMMA DATA DEF DIM DIVIDE END EQUALS FLOAT FOR GE GOSUB GOTO GT ID IF INTEGER LE LET LIST LPAREN LT MINUS NE NEW NEWLINE NEXT PLUS POWER PRINT READ REM RETURN RPAREN RUN SEMI STEP STOP STRING THEN TIMES TOprogram : program statement\n | statementprogram : errorstatement : INTEGER command NEWLINEstatement : RUN NEWLINE\n | LIST NEWLINE\n | NEW NEWLINEstatement : INTEGER NEWLINEstatement : INTEGER error NEWLINEstatement : NEWLINEcommand : LET variable EQUALS exprcommand : LET variable EQUALS errorcommand : READ varlistcommand : READ errorcommand : DATA numlistcommand : DATA errorcommand : PRINT plist optendcommand : PRINT erroroptend : COMMA \n | SEMI\n |command : PRINTcommand : GOTO INTEGERcommand : GOTO errorcommand : IF relexpr THEN INTEGERcommand : IF error THEN INTEGERcommand : IF relexpr THEN errorcommand : FOR ID EQUALS expr TO expr optstepcommand : FOR ID EQUALS error TO expr optstepcommand : FOR ID EQUALS expr TO error optstepcommand : FOR ID EQUALS expr TO expr STEP erroroptstep : STEP expr\n | emptycommand : NEXT IDcommand : NEXT errorcommand : ENDcommand : REMcommand : STOPcommand : DEF ID LPAREN ID RPAREN EQUALS exprcommand : DEF ID LPAREN ID RPAREN EQUALS errorcommand : DEF ID LPAREN error RPAREN EQUALS exprcommand : GOSUB INTEGERcommand : GOSUB errorcommand : RETURNcommand : DIM dimlistcommand : DIM errordimlist : dimlist COMMA dimitem\n | dimitemdimitem : ID LPAREN INTEGER RPARENdimitem : ID LPAREN INTEGER COMMA INTEGER RPARENexpr : expr PLUS expr\n | expr MINUS expr\n | expr TIMES expr\n | expr DIVIDE expr\n | expr POWER exprexpr : INTEGER\n | FLOATexpr : variableexpr : LPAREN expr RPARENexpr : MINUS expr %prec UMINUSrelexpr : expr LT expr\n | expr LE expr\n | expr GT expr\n | expr GE expr\n | expr EQUALS expr\n | expr NE exprvariable : ID\n | ID LPAREN expr RPAREN\n | ID LPAREN expr COMMA expr RPARENvarlist : varlist COMMA variable\n | variablenumlist : numlist COMMA number\n | numbernumber : INTEGER\n | FLOATnumber : MINUS INTEGER\n | MINUS FLOATplist : plist COMMA pitem\n | pitempitem : STRINGpitem : STRING exprpitem : exprempty : ' _lr_action_items = {'error':([0,4,14,15,16,17,18,20,25,27,69,86,94,95,127,137,142,],[3,12,36,39,45,55,57,61,64,66,99,111,120,122,135,148,152,]),'INTEGER':([0,1,2,3,5,9,11,15,16,17,18,25,28,29,30,31,32,43,47,49,53,69,70,72,76,79,80,81,82,83,86,87,88,89,90,91,92,93,94,97,126,127,128,132,137,138,142,145,],[4,4,-2,-3,-10,-1,-8,41,50,54,50,63,-5,-6,-7,-4,-9,73,50,50,50,50,50,41,50,50,50,50,50,50,110,112,50,50,50,50,50,50,50,124,50,50,50,139,50,50,50,50,]),'RUN':([0,1,2,3,5,9,11,28,29,30,31,32,],[6,6,-2,-3,-10,-1,-8,-5,-6,-7,-4,-9,]),'LIST':([0,1,2,3,5,9,11,28,29,30,31,32,],[7,7,-2,-3,-10,-1,-8,-5,-6,-7,-4,-9,]),'NEW':([0,1,2,3,5,9,11,28,29,30,31,32,],[8,8,-2,-3,-10,-1,-8,-5,-6,-7,-4,-9,]),'NEWLINE':([0,1,2,3,4,5,6,7,8,9,10,11,12,16,21,22,23,26,28,29,30,31,32,34,35,36,37,38,39,40,41,42,44,45,46,47,48,50,51,52,54,55,60,61,63,64,65,66,67,73,74,75,76,77,78,84,98,99,101,102,103,104,105,106,107,108,109,110,111,112,123,125,131,134,135,136,140,141,143,144,146,147,148,149,150,151,152,],[5,5,-2,-3,11,-10,28,29,30,-1,31,-8,32,-22,-36,-37,-38,-44,-5,-6,-7,-4,-9,-67,-13,-14,-71,-15,-16,-73,-74,-75,-21,-18,-79,-80,-82,-56,-57,-58,-23,-24,-34,-35,-42,-43,-45,-46,-48,-76,-77,-17,-19,-20,-81,-60,-11,-12,-70,-72,-78,-51,-52,-53,-54,-55,-59,-25,-27,-26,-47,-68,-49,-83,-83,-83,-69,-28,-33,-30,-29,-39,-40,-41,-50,-32,-31,]),'$end':([1,2,3,5,9,11,28,29,30,31,32,],[0,-2,-3,-10,-1,-8,-5,-6,-7,-4,-9,]),'LET':([4,],[13,]),'READ':([4,],[14,]),'DATA':([4,],[15,]),'PRINT':([4,],[16,]),'GOTO':([4,],[17,]),'IF':([4,],[18,]),'FOR':([4,],[19,]),'NEXT':([4,],[20,]),'END':([4,],[21,]),'REM':([4,],[22,]),'STOP':([4,],[23,]),'DEF':([4,],[24,]),'GOSUB':([4,],[25,]),'RETURN':([4,],[26,]),'DIM':([4,],[27,]),'ID':([13,14,16,18,19,20,24,27,47,49,53,69,70,71,76,79,80,81,82,83,88,89,90,91,92,93,94,95,96,126,127,128,137,138,142,145,],[34,34,34,34,59,60,62,68,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,121,68,34,34,34,34,34,34,34,]),'FLOAT':([15,16,18,43,47,49,53,69,70,72,76,79,80,81,82,83,88,89,90,91,92,93,94,126,127,128,137,138,142,145,],[42,51,51,74,51,51,51,51,51,42,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,]),'MINUS':([15,16,18,34,47,48,49,50,51,52,53,58,69,70,72,76,78,79,80,81,82,83,84,85,88,89,90,91,92,93,94,98,100,104,105,106,107,108,109,113,114,115,116,117,118,119,125,126,127,128,133,134,136,137,138,140,142,145,147,149,151,],[43,49,49,-67,49,80,49,-56,-57,-58,49,80,49,49,43,49,80,49,49,49,49,49,-60,80,49,49,49,49,49,49,49,80,80,-51,-52,-53,-54,-55,-59,80,80,80,80,80,80,80,-68,49,49,49,80,80,80,49,49,-69,49,49,80,80,80,]),'STRING':([16,76,],[47,47,]),'LPAREN':([16,18,34,47,49,53,62,68,69,70,76,79,80,81,82,83,88,89,90,91,92,93,94,126,127,128,137,138,142,145,],[53,53,70,53,53,53,95,97,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,]),'EQUALS':([33,34,50,51,52,58,59,84,104,105,106,107,108,109,125,129,130,140,],[69,-67,-56,-57,-58,92,94,-60,-51,-52,-53,-54,-55,-59,-68,137,138,-69,]),'COMMA':([34,35,37,38,40,41,42,44,46,47,48,50,51,52,65,67,73,74,78,84,100,101,102,103,104,105,106,107,108,109,123,124,125,131,140,150,],[-67,71,-71,72,-73,-74,-75,76,-79,-80,-82,-56,-57,-58,96,-48,-76,-77,-81,-60,126,-70,-72,-78,-51,-52,-53,-54,-55,-59,-47,132,-68,-49,-69,-50,]),'PLUS':([34,48,50,51,52,58,78,84,85,98,100,104,105,106,107,108,109,113,114,115,116,117,118,119,125,133,134,136,140,147,149,151,],[-67,79,-56,-57,-58,79,79,-60,79,79,79,-51,-52,-53,-54,-55,-59,79,79,79,79,79,79,79,-68,79,79,79,-69,79,79,79,]),'TIMES':([34,48,50,51,52,58,78,84,85,98,100,104,105,106,107,108,109,113,114,115,116,117,118,119,125,133,134,136,140,147,149,151,],[-67,81,-56,-57,-58,81,81,-60,81,81,81,81,81,-53,-54,-55,-59,81,81,81,81,81,81,81,-68,81,81,81,-69,81,81,81,]),'DIVIDE':([34,48,50,51,52,58,78,84,85,98,100,104,105,106,107,108,109,113,114,115,116,117,118,119,125,133,134,136,140,147,149,151,],[-67,82,-56,-57,-58,82,82,-60,82,82,82,82,82,-53,-54,-55,-59,82,82,82,82,82,82,82,-68,82,82,82,-69,82,82,82,]),'POWER':([34,48,50,51,52,58,78,84,85,98,100,104,105,106,107,108,109,113,114,115,116,117,118,119,125,133,134,136,140,147,149,151,],[-67,83,-56,-57,-58,83,83,-60,83,83,83,83,83,83,83,-55,-59,83,83,83,83,83,83,83,-68,83,83,83,-69,83,83,83,]),'SEMI':([34,44,46,47,48,50,51,52,78,84,103,104,105,106,107,108,109,125,140,],[-67,77,-79,-80,-82,-56,-57,-58,-81,-60,-78,-51,-52,-53,-54,-55,-59,-68,-69,]),'LT':([34,50,51,52,58,84,104,105,106,107,108,109,125,140,],[-67,-56,-57,-58,88,-60,-51,-52,-53,-54,-55,-59,-68,-69,]),'LE':([34,50,51,52,58,84,104,105,106,107,108,109,125,140,],[-67,-56,-57,-58,89,-60,-51,-52,-53,-54,-55,-59,-68,-69,]),'GT':([34,50,51,52,58,84,104,105,106,107,108,109,125,140,],[-67,-56,-57,-58,90,-60,-51,-52,-53,-54,-55,-59,-68,-69,]),'GE':([34,50,51,52,58,84,104,105,106,107,108,109,125,140,],[-67,-56,-57,-58,91,-60,-51,-52,-53,-54,-55,-59,-68,-69,]),'NE':([34,50,51,52,58,84,104,105,106,107,108,109,125,140,],[-67,-56,-57,-58,93,-60,-51,-52,-53,-54,-55,-59,-68,-69,]),'RPAREN':([34,50,51,52,84,85,100,104,105,106,107,108,109,121,122,124,125,133,139,140,],[-67,-56,-57,-58,-60,109,125,-51,-52,-53,-54,-55,-59,129,130,131,-68,140,150,-69,]),'THEN':([34,50,51,52,56,57,84,104,105,106,107,108,109,113,114,115,116,117,118,125,140,],[-67,-56,-57,-58,86,87,-60,-51,-52,-53,-54,-55,-59,-61,-62,-63,-64,-65,-66,-68,-69,]),'TO':([34,50,51,52,84,104,105,106,107,108,109,119,120,125,140,],[-67,-56,-57,-58,-60,-51,-52,-53,-54,-55,-59,127,128,-68,-69,]),'STEP':([34,50,51,52,84,104,105,106,107,108,109,125,134,135,136,140,],[-67,-56,-57,-58,-60,-51,-52,-53,-54,-55,-59,-68,142,145,145,-69,]),} _lr_action = {} for _k, _v in _lr_action_items.items(): for _x,_y in zip(_v[0],_v[1]): if not _x in _lr_action: _lr_action[_x] = {} _lr_action[_x][_k] = _y del _lr_action_items _lr_goto_items = {'program':([0,],[1,]),'statement':([0,1,],[2,9,]),'command':([4,],[10,]),'variable':([13,14,16,18,47,49,53,69,70,71,76,79,80,81,82,83,88,89,90,91,92,93,94,126,127,128,137,138,142,145,],[33,37,52,52,52,52,52,52,52,101,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,]),'varlist':([14,],[35,]),'numlist':([15,],[38,]),'number':([15,72,],[40,102,]),'plist':([16,],[44,]),'pitem':([16,76,],[46,103,]),'expr':([16,18,47,49,53,69,70,76,79,80,81,82,83,88,89,90,91,92,93,94,126,127,128,137,138,142,145,],[48,58,78,84,85,98,100,48,104,105,106,107,108,113,114,115,116,117,118,119,133,134,136,147,149,151,151,]),'relexpr':([18,],[56,]),'dimlist':([27,],[65,]),'dimitem':([27,96,],[67,123,]),'optend':([44,],[75,]),'optstep':([134,135,136,],[141,144,146,]),'empty':([134,135,136,],[143,143,143,]),} _lr_goto = {} for _k, _v in _lr_goto_items.items(): for _x, _y in zip(_v[0], _v[1]): if not _x in _lr_goto: _lr_goto[_x] = {} _lr_goto[_x][_k] = _y del _lr_goto_items _lr_productions = [ ("S' -> program","S'",1,None,None,None), ('program -> program statement','program',2,'p_program','basparse.py',21), ('program -> statement','program',1,'p_program','basparse.py',22), ('program -> error','program',1,'p_program_error','basparse.py',41), ('statement -> INTEGER command NEWLINE','statement',3,'p_statement','basparse.py',49), ('statement -> RUN NEWLINE','statement',2,'p_statement_interactive','basparse.py',62), ('statement -> LIST NEWLINE','statement',2,'p_statement_interactive','basparse.py',63), ('statement -> NEW NEWLINE','statement',2,'p_statement_interactive','basparse.py',64), ('statement -> INTEGER NEWLINE','statement',2,'p_statement_blank','basparse.py',71), ('statement -> INTEGER error NEWLINE','statement',3,'p_statement_bad','basparse.py',78), ('statement -> NEWLINE','statement',1,'p_statement_newline','basparse.py',87), ('command -> LET variable EQUALS expr','command',4,'p_command_let','basparse.py',94), ('command -> LET variable EQUALS error','command',4,'p_command_let_bad','basparse.py',99), ('command -> READ varlist','command',2,'p_command_read','basparse.py',106), ('command -> READ error','command',2,'p_command_read_bad','basparse.py',111), ('command -> DATA numlist','command',2,'p_command_data','basparse.py',118), ('command -> DATA error','command',2,'p_command_data_bad','basparse.py',123), ('command -> PRINT plist optend','command',3,'p_command_print','basparse.py',130), ('command -> PRINT error','command',2,'p_command_print_bad','basparse.py',135), ('optend -> COMMA','optend',1,'p_optend','basparse.py',142), ('optend -> SEMI','optend',1,'p_optend','basparse.py',143), ('optend -> <empty>','optend',0,'p_optend','basparse.py',144), ('command -> PRINT','command',1,'p_command_print_empty','basparse.py',154), ('command -> GOTO INTEGER','command',2,'p_command_goto','basparse.py',161), ('command -> GOTO error','command',2,'p_command_goto_bad','basparse.py',166), ('command -> IF relexpr THEN INTEGER','command',4,'p_command_if','basparse.py',173), ('command -> IF error THEN INTEGER','command',4,'p_command_if_bad','basparse.py',178), ('command -> IF relexpr THEN error','command',4,'p_command_if_bad2','basparse.py',183), ('command -> FOR ID EQUALS expr TO expr optstep','command',7,'p_command_for','basparse.py',190), ('command -> FOR ID EQUALS error TO expr optstep','command',7,'p_command_for_bad_initial','basparse.py',195), ('command -> FOR ID EQUALS expr TO error optstep','command',7,'p_command_for_bad_final','basparse.py',200), ('command -> FOR ID EQUALS expr TO expr STEP error','command',8,'p_command_for_bad_step','basparse.py',205), ('optstep -> STEP expr','optstep',2,'p_optstep','basparse.py',212), ('optstep -> empty','optstep',1,'p_optstep','basparse.py',213), ('command -> NEXT ID','command',2,'p_command_next','basparse.py',223), ('command -> NEXT error','command',2,'p_command_next_bad','basparse.py',229), ('command -> END','command',1,'p_command_end','basparse.py',236), ('command -> REM','command',1,'p_command_rem','basparse.py',243), ('command -> STOP','command',1,'p_command_stop','basparse.py',250), ('command -> DEF ID LPAREN ID RPAREN EQUALS expr','command',7,'p_command_def','basparse.py',257), ('command -> DEF ID LPAREN ID RPAREN EQUALS error','command',7,'p_command_def_bad_rhs','basparse.py',262), ('command -> DEF ID LPAREN error RPAREN EQUALS expr','command',7,'p_command_def_bad_arg','basparse.py',267), ('command -> GOSUB INTEGER','command',2,'p_command_gosub','basparse.py',274), ('command -> GOSUB error','command',2,'p_command_gosub_bad','basparse.py',279), ('command -> RETURN','command',1,'p_command_return','basparse.py',286), ('command -> DIM dimlist','command',2,'p_command_dim','basparse.py',293), ('command -> DIM error','command',2,'p_command_dim_bad','basparse.py',298), ('dimlist -> dimlist COMMA dimitem','dimlist',3,'p_dimlist','basparse.py',305), ('dimlist -> dimitem','dimlist',1,'p_dimlist','basparse.py',306), ('dimitem -> ID LPAREN INTEGER RPAREN','dimitem',4,'p_dimitem_single','basparse.py',317), ('dimitem -> ID LPAREN INTEGER COMMA INTEGER RPAREN','dimitem',6,'p_dimitem_double','basparse.py',322), ('expr -> expr PLUS expr','expr',3,'p_expr_binary','basparse.py',329), ('expr -> expr MINUS expr','expr',3,'p_expr_binary','basparse.py',330), ('expr -> expr TIMES expr','expr',3,'p_expr_binary','basparse.py',331), ('expr -> expr DIVIDE expr','expr',3,'p_expr_binary','basparse.py',332), ('expr -> expr POWER expr','expr',3,'p_expr_binary','basparse.py',333), ('expr -> INTEGER','expr',1,'p_expr_number','basparse.py',339), ('expr -> FLOAT','expr',1,'p_expr_number','basparse.py',340), ('expr -> variable','expr',1,'p_expr_variable','basparse.py',345), ('expr -> LPAREN expr RPAREN','expr',3,'p_expr_group','basparse.py',350), ('expr -> MINUS expr','expr',2,'p_expr_unary','basparse.py',355), ('relexpr -> expr LT expr','relexpr',3,'p_relexpr','basparse.py',362), ('relexpr -> expr LE expr','relexpr',3,'p_relexpr','basparse.py',363), ('relexpr -> expr GT expr','relexpr',3,'p_relexpr','basparse.py',364), ('relexpr -> expr GE expr','relexpr',3,'p_relexpr','basparse.py',365), ('relexpr -> expr EQUALS expr','relexpr',3,'p_relexpr','basparse.py',366), ('relexpr -> expr NE expr','relexpr',3,'p_relexpr','basparse.py',367), ('variable -> ID','variable',1,'p_variable','basparse.py',374), ('variable -> ID LPAREN expr RPAREN','variable',4,'p_variable','basparse.py',375), ('variable -> ID LPAREN expr COMMA expr RPAREN','variable',6,'p_variable','basparse.py',376), ('varlist -> varlist COMMA variable','varlist',3,'p_varlist','basparse.py',388), ('varlist -> variable','varlist',1,'p_varlist','basparse.py',389), ('numlist -> numlist COMMA number','numlist',3,'p_numlist','basparse.py',400), ('numlist -> number','numlist',1,'p_numlist','basparse.py',401), ('number -> INTEGER','number',1,'p_number','basparse.py',413), ('number -> FLOAT','number',1,'p_number','basparse.py',414), ('number -> MINUS INTEGER','number',2,'p_number_signed','basparse.py',421), ('number -> MINUS FLOAT','number',2,'p_number_signed','basparse.py',422), ('plist -> plist COMMA pitem','plist',3,'p_plist','basparse.py',430), ('plist -> pitem','plist',1,'p_plist','basparse.py',431), ('pitem -> STRING','pitem',1,'p_item_string','basparse.py',440), ('pitem -> STRING expr','pitem',2,'p_item_string_expr','basparse.py',445), ('pitem -> expr','pitem',1,'p_item_expr','basparse.py',450), ('empty -> <empty>','empty',0,'p_empty','basparse.py',457), ]
_tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'leftPLUSMINUSleftTIMESDIVIDEleftPOWERrightUMINUSCOMMA DATA DEF DIM DIVIDE END EQUALS FLOAT FOR GE GOSUB GOTO GT ID IF INTEGER LE LET LIST LPAREN LT MINUS NE NEW NEWLINE NEXT PLUS POWER PRINT READ REM RETURN RPAREN RUN SEMI STEP STOP STRING THEN TIMES TOprogram : program statement\n | statementprogram : errorstatement : INTEGER command NEWLINEstatement : RUN NEWLINE\n | LIST NEWLINE\n | NEW NEWLINEstatement : INTEGER NEWLINEstatement : INTEGER error NEWLINEstatement : NEWLINEcommand : LET variable EQUALS exprcommand : LET variable EQUALS errorcommand : READ varlistcommand : READ errorcommand : DATA numlistcommand : DATA errorcommand : PRINT plist optendcommand : PRINT erroroptend : COMMA \n | SEMI\n |command : PRINTcommand : GOTO INTEGERcommand : GOTO errorcommand : IF relexpr THEN INTEGERcommand : IF error THEN INTEGERcommand : IF relexpr THEN errorcommand : FOR ID EQUALS expr TO expr optstepcommand : FOR ID EQUALS error TO expr optstepcommand : FOR ID EQUALS expr TO error optstepcommand : FOR ID EQUALS expr TO expr STEP erroroptstep : STEP expr\n | emptycommand : NEXT IDcommand : NEXT errorcommand : ENDcommand : REMcommand : STOPcommand : DEF ID LPAREN ID RPAREN EQUALS exprcommand : DEF ID LPAREN ID RPAREN EQUALS errorcommand : DEF ID LPAREN error RPAREN EQUALS exprcommand : GOSUB INTEGERcommand : GOSUB errorcommand : RETURNcommand : DIM dimlistcommand : DIM errordimlist : dimlist COMMA dimitem\n | dimitemdimitem : ID LPAREN INTEGER RPARENdimitem : ID LPAREN INTEGER COMMA INTEGER RPARENexpr : expr PLUS expr\n | expr MINUS expr\n | expr TIMES expr\n | expr DIVIDE expr\n | expr POWER exprexpr : INTEGER\n | FLOATexpr : variableexpr : LPAREN expr RPARENexpr : MINUS expr %prec UMINUSrelexpr : expr LT expr\n | expr LE expr\n | expr GT expr\n | expr GE expr\n | expr EQUALS expr\n | expr NE exprvariable : ID\n | ID LPAREN expr RPAREN\n | ID LPAREN expr COMMA expr RPARENvarlist : varlist COMMA variable\n | variablenumlist : numlist COMMA number\n | numbernumber : INTEGER\n | FLOATnumber : MINUS INTEGER\n | MINUS FLOATplist : plist COMMA pitem\n | pitempitem : STRINGpitem : STRING exprpitem : exprempty : ' _lr_action_items = {'error': ([0, 4, 14, 15, 16, 17, 18, 20, 25, 27, 69, 86, 94, 95, 127, 137, 142], [3, 12, 36, 39, 45, 55, 57, 61, 64, 66, 99, 111, 120, 122, 135, 148, 152]), 'INTEGER': ([0, 1, 2, 3, 5, 9, 11, 15, 16, 17, 18, 25, 28, 29, 30, 31, 32, 43, 47, 49, 53, 69, 70, 72, 76, 79, 80, 81, 82, 83, 86, 87, 88, 89, 90, 91, 92, 93, 94, 97, 126, 127, 128, 132, 137, 138, 142, 145], [4, 4, -2, -3, -10, -1, -8, 41, 50, 54, 50, 63, -5, -6, -7, -4, -9, 73, 50, 50, 50, 50, 50, 41, 50, 50, 50, 50, 50, 50, 110, 112, 50, 50, 50, 50, 50, 50, 50, 124, 50, 50, 50, 139, 50, 50, 50, 50]), 'RUN': ([0, 1, 2, 3, 5, 9, 11, 28, 29, 30, 31, 32], [6, 6, -2, -3, -10, -1, -8, -5, -6, -7, -4, -9]), 'LIST': ([0, 1, 2, 3, 5, 9, 11, 28, 29, 30, 31, 32], [7, 7, -2, -3, -10, -1, -8, -5, -6, -7, -4, -9]), 'NEW': ([0, 1, 2, 3, 5, 9, 11, 28, 29, 30, 31, 32], [8, 8, -2, -3, -10, -1, -8, -5, -6, -7, -4, -9]), 'NEWLINE': ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 16, 21, 22, 23, 26, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 50, 51, 52, 54, 55, 60, 61, 63, 64, 65, 66, 67, 73, 74, 75, 76, 77, 78, 84, 98, 99, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 123, 125, 131, 134, 135, 136, 140, 141, 143, 144, 146, 147, 148, 149, 150, 151, 152], [5, 5, -2, -3, 11, -10, 28, 29, 30, -1, 31, -8, 32, -22, -36, -37, -38, -44, -5, -6, -7, -4, -9, -67, -13, -14, -71, -15, -16, -73, -74, -75, -21, -18, -79, -80, -82, -56, -57, -58, -23, -24, -34, -35, -42, -43, -45, -46, -48, -76, -77, -17, -19, -20, -81, -60, -11, -12, -70, -72, -78, -51, -52, -53, -54, -55, -59, -25, -27, -26, -47, -68, -49, -83, -83, -83, -69, -28, -33, -30, -29, -39, -40, -41, -50, -32, -31]), '$end': ([1, 2, 3, 5, 9, 11, 28, 29, 30, 31, 32], [0, -2, -3, -10, -1, -8, -5, -6, -7, -4, -9]), 'LET': ([4], [13]), 'READ': ([4], [14]), 'DATA': ([4], [15]), 'PRINT': ([4], [16]), 'GOTO': ([4], [17]), 'IF': ([4], [18]), 'FOR': ([4], [19]), 'NEXT': ([4], [20]), 'END': ([4], [21]), 'REM': ([4], [22]), 'STOP': ([4], [23]), 'DEF': ([4], [24]), 'GOSUB': ([4], [25]), 'RETURN': ([4], [26]), 'DIM': ([4], [27]), 'ID': ([13, 14, 16, 18, 19, 20, 24, 27, 47, 49, 53, 69, 70, 71, 76, 79, 80, 81, 82, 83, 88, 89, 90, 91, 92, 93, 94, 95, 96, 126, 127, 128, 137, 138, 142, 145], [34, 34, 34, 34, 59, 60, 62, 68, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 121, 68, 34, 34, 34, 34, 34, 34, 34]), 'FLOAT': ([15, 16, 18, 43, 47, 49, 53, 69, 70, 72, 76, 79, 80, 81, 82, 83, 88, 89, 90, 91, 92, 93, 94, 126, 127, 128, 137, 138, 142, 145], [42, 51, 51, 74, 51, 51, 51, 51, 51, 42, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51]), 'MINUS': ([15, 16, 18, 34, 47, 48, 49, 50, 51, 52, 53, 58, 69, 70, 72, 76, 78, 79, 80, 81, 82, 83, 84, 85, 88, 89, 90, 91, 92, 93, 94, 98, 100, 104, 105, 106, 107, 108, 109, 113, 114, 115, 116, 117, 118, 119, 125, 126, 127, 128, 133, 134, 136, 137, 138, 140, 142, 145, 147, 149, 151], [43, 49, 49, -67, 49, 80, 49, -56, -57, -58, 49, 80, 49, 49, 43, 49, 80, 49, 49, 49, 49, 49, -60, 80, 49, 49, 49, 49, 49, 49, 49, 80, 80, -51, -52, -53, -54, -55, -59, 80, 80, 80, 80, 80, 80, 80, -68, 49, 49, 49, 80, 80, 80, 49, 49, -69, 49, 49, 80, 80, 80]), 'STRING': ([16, 76], [47, 47]), 'LPAREN': ([16, 18, 34, 47, 49, 53, 62, 68, 69, 70, 76, 79, 80, 81, 82, 83, 88, 89, 90, 91, 92, 93, 94, 126, 127, 128, 137, 138, 142, 145], [53, 53, 70, 53, 53, 53, 95, 97, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53]), 'EQUALS': ([33, 34, 50, 51, 52, 58, 59, 84, 104, 105, 106, 107, 108, 109, 125, 129, 130, 140], [69, -67, -56, -57, -58, 92, 94, -60, -51, -52, -53, -54, -55, -59, -68, 137, 138, -69]), 'COMMA': ([34, 35, 37, 38, 40, 41, 42, 44, 46, 47, 48, 50, 51, 52, 65, 67, 73, 74, 78, 84, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 123, 124, 125, 131, 140, 150], [-67, 71, -71, 72, -73, -74, -75, 76, -79, -80, -82, -56, -57, -58, 96, -48, -76, -77, -81, -60, 126, -70, -72, -78, -51, -52, -53, -54, -55, -59, -47, 132, -68, -49, -69, -50]), 'PLUS': ([34, 48, 50, 51, 52, 58, 78, 84, 85, 98, 100, 104, 105, 106, 107, 108, 109, 113, 114, 115, 116, 117, 118, 119, 125, 133, 134, 136, 140, 147, 149, 151], [-67, 79, -56, -57, -58, 79, 79, -60, 79, 79, 79, -51, -52, -53, -54, -55, -59, 79, 79, 79, 79, 79, 79, 79, -68, 79, 79, 79, -69, 79, 79, 79]), 'TIMES': ([34, 48, 50, 51, 52, 58, 78, 84, 85, 98, 100, 104, 105, 106, 107, 108, 109, 113, 114, 115, 116, 117, 118, 119, 125, 133, 134, 136, 140, 147, 149, 151], [-67, 81, -56, -57, -58, 81, 81, -60, 81, 81, 81, 81, 81, -53, -54, -55, -59, 81, 81, 81, 81, 81, 81, 81, -68, 81, 81, 81, -69, 81, 81, 81]), 'DIVIDE': ([34, 48, 50, 51, 52, 58, 78, 84, 85, 98, 100, 104, 105, 106, 107, 108, 109, 113, 114, 115, 116, 117, 118, 119, 125, 133, 134, 136, 140, 147, 149, 151], [-67, 82, -56, -57, -58, 82, 82, -60, 82, 82, 82, 82, 82, -53, -54, -55, -59, 82, 82, 82, 82, 82, 82, 82, -68, 82, 82, 82, -69, 82, 82, 82]), 'POWER': ([34, 48, 50, 51, 52, 58, 78, 84, 85, 98, 100, 104, 105, 106, 107, 108, 109, 113, 114, 115, 116, 117, 118, 119, 125, 133, 134, 136, 140, 147, 149, 151], [-67, 83, -56, -57, -58, 83, 83, -60, 83, 83, 83, 83, 83, 83, 83, -55, -59, 83, 83, 83, 83, 83, 83, 83, -68, 83, 83, 83, -69, 83, 83, 83]), 'SEMI': ([34, 44, 46, 47, 48, 50, 51, 52, 78, 84, 103, 104, 105, 106, 107, 108, 109, 125, 140], [-67, 77, -79, -80, -82, -56, -57, -58, -81, -60, -78, -51, -52, -53, -54, -55, -59, -68, -69]), 'LT': ([34, 50, 51, 52, 58, 84, 104, 105, 106, 107, 108, 109, 125, 140], [-67, -56, -57, -58, 88, -60, -51, -52, -53, -54, -55, -59, -68, -69]), 'LE': ([34, 50, 51, 52, 58, 84, 104, 105, 106, 107, 108, 109, 125, 140], [-67, -56, -57, -58, 89, -60, -51, -52, -53, -54, -55, -59, -68, -69]), 'GT': ([34, 50, 51, 52, 58, 84, 104, 105, 106, 107, 108, 109, 125, 140], [-67, -56, -57, -58, 90, -60, -51, -52, -53, -54, -55, -59, -68, -69]), 'GE': ([34, 50, 51, 52, 58, 84, 104, 105, 106, 107, 108, 109, 125, 140], [-67, -56, -57, -58, 91, -60, -51, -52, -53, -54, -55, -59, -68, -69]), 'NE': ([34, 50, 51, 52, 58, 84, 104, 105, 106, 107, 108, 109, 125, 140], [-67, -56, -57, -58, 93, -60, -51, -52, -53, -54, -55, -59, -68, -69]), 'RPAREN': ([34, 50, 51, 52, 84, 85, 100, 104, 105, 106, 107, 108, 109, 121, 122, 124, 125, 133, 139, 140], [-67, -56, -57, -58, -60, 109, 125, -51, -52, -53, -54, -55, -59, 129, 130, 131, -68, 140, 150, -69]), 'THEN': ([34, 50, 51, 52, 56, 57, 84, 104, 105, 106, 107, 108, 109, 113, 114, 115, 116, 117, 118, 125, 140], [-67, -56, -57, -58, 86, 87, -60, -51, -52, -53, -54, -55, -59, -61, -62, -63, -64, -65, -66, -68, -69]), 'TO': ([34, 50, 51, 52, 84, 104, 105, 106, 107, 108, 109, 119, 120, 125, 140], [-67, -56, -57, -58, -60, -51, -52, -53, -54, -55, -59, 127, 128, -68, -69]), 'STEP': ([34, 50, 51, 52, 84, 104, 105, 106, 107, 108, 109, 125, 134, 135, 136, 140], [-67, -56, -57, -58, -60, -51, -52, -53, -54, -55, -59, -68, 142, 145, 145, -69])} _lr_action = {} for (_k, _v) in _lr_action_items.items(): for (_x, _y) in zip(_v[0], _v[1]): if not _x in _lr_action: _lr_action[_x] = {} _lr_action[_x][_k] = _y del _lr_action_items _lr_goto_items = {'program': ([0], [1]), 'statement': ([0, 1], [2, 9]), 'command': ([4], [10]), 'variable': ([13, 14, 16, 18, 47, 49, 53, 69, 70, 71, 76, 79, 80, 81, 82, 83, 88, 89, 90, 91, 92, 93, 94, 126, 127, 128, 137, 138, 142, 145], [33, 37, 52, 52, 52, 52, 52, 52, 52, 101, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52]), 'varlist': ([14], [35]), 'numlist': ([15], [38]), 'number': ([15, 72], [40, 102]), 'plist': ([16], [44]), 'pitem': ([16, 76], [46, 103]), 'expr': ([16, 18, 47, 49, 53, 69, 70, 76, 79, 80, 81, 82, 83, 88, 89, 90, 91, 92, 93, 94, 126, 127, 128, 137, 138, 142, 145], [48, 58, 78, 84, 85, 98, 100, 48, 104, 105, 106, 107, 108, 113, 114, 115, 116, 117, 118, 119, 133, 134, 136, 147, 149, 151, 151]), 'relexpr': ([18], [56]), 'dimlist': ([27], [65]), 'dimitem': ([27, 96], [67, 123]), 'optend': ([44], [75]), 'optstep': ([134, 135, 136], [141, 144, 146]), 'empty': ([134, 135, 136], [143, 143, 143])} _lr_goto = {} for (_k, _v) in _lr_goto_items.items(): for (_x, _y) in zip(_v[0], _v[1]): if not _x in _lr_goto: _lr_goto[_x] = {} _lr_goto[_x][_k] = _y del _lr_goto_items _lr_productions = [("S' -> program", "S'", 1, None, None, None), ('program -> program statement', 'program', 2, 'p_program', 'basparse.py', 21), ('program -> statement', 'program', 1, 'p_program', 'basparse.py', 22), ('program -> error', 'program', 1, 'p_program_error', 'basparse.py', 41), ('statement -> INTEGER command NEWLINE', 'statement', 3, 'p_statement', 'basparse.py', 49), ('statement -> RUN NEWLINE', 'statement', 2, 'p_statement_interactive', 'basparse.py', 62), ('statement -> LIST NEWLINE', 'statement', 2, 'p_statement_interactive', 'basparse.py', 63), ('statement -> NEW NEWLINE', 'statement', 2, 'p_statement_interactive', 'basparse.py', 64), ('statement -> INTEGER NEWLINE', 'statement', 2, 'p_statement_blank', 'basparse.py', 71), ('statement -> INTEGER error NEWLINE', 'statement', 3, 'p_statement_bad', 'basparse.py', 78), ('statement -> NEWLINE', 'statement', 1, 'p_statement_newline', 'basparse.py', 87), ('command -> LET variable EQUALS expr', 'command', 4, 'p_command_let', 'basparse.py', 94), ('command -> LET variable EQUALS error', 'command', 4, 'p_command_let_bad', 'basparse.py', 99), ('command -> READ varlist', 'command', 2, 'p_command_read', 'basparse.py', 106), ('command -> READ error', 'command', 2, 'p_command_read_bad', 'basparse.py', 111), ('command -> DATA numlist', 'command', 2, 'p_command_data', 'basparse.py', 118), ('command -> DATA error', 'command', 2, 'p_command_data_bad', 'basparse.py', 123), ('command -> PRINT plist optend', 'command', 3, 'p_command_print', 'basparse.py', 130), ('command -> PRINT error', 'command', 2, 'p_command_print_bad', 'basparse.py', 135), ('optend -> COMMA', 'optend', 1, 'p_optend', 'basparse.py', 142), ('optend -> SEMI', 'optend', 1, 'p_optend', 'basparse.py', 143), ('optend -> <empty>', 'optend', 0, 'p_optend', 'basparse.py', 144), ('command -> PRINT', 'command', 1, 'p_command_print_empty', 'basparse.py', 154), ('command -> GOTO INTEGER', 'command', 2, 'p_command_goto', 'basparse.py', 161), ('command -> GOTO error', 'command', 2, 'p_command_goto_bad', 'basparse.py', 166), ('command -> IF relexpr THEN INTEGER', 'command', 4, 'p_command_if', 'basparse.py', 173), ('command -> IF error THEN INTEGER', 'command', 4, 'p_command_if_bad', 'basparse.py', 178), ('command -> IF relexpr THEN error', 'command', 4, 'p_command_if_bad2', 'basparse.py', 183), ('command -> FOR ID EQUALS expr TO expr optstep', 'command', 7, 'p_command_for', 'basparse.py', 190), ('command -> FOR ID EQUALS error TO expr optstep', 'command', 7, 'p_command_for_bad_initial', 'basparse.py', 195), ('command -> FOR ID EQUALS expr TO error optstep', 'command', 7, 'p_command_for_bad_final', 'basparse.py', 200), ('command -> FOR ID EQUALS expr TO expr STEP error', 'command', 8, 'p_command_for_bad_step', 'basparse.py', 205), ('optstep -> STEP expr', 'optstep', 2, 'p_optstep', 'basparse.py', 212), ('optstep -> empty', 'optstep', 1, 'p_optstep', 'basparse.py', 213), ('command -> NEXT ID', 'command', 2, 'p_command_next', 'basparse.py', 223), ('command -> NEXT error', 'command', 2, 'p_command_next_bad', 'basparse.py', 229), ('command -> END', 'command', 1, 'p_command_end', 'basparse.py', 236), ('command -> REM', 'command', 1, 'p_command_rem', 'basparse.py', 243), ('command -> STOP', 'command', 1, 'p_command_stop', 'basparse.py', 250), ('command -> DEF ID LPAREN ID RPAREN EQUALS expr', 'command', 7, 'p_command_def', 'basparse.py', 257), ('command -> DEF ID LPAREN ID RPAREN EQUALS error', 'command', 7, 'p_command_def_bad_rhs', 'basparse.py', 262), ('command -> DEF ID LPAREN error RPAREN EQUALS expr', 'command', 7, 'p_command_def_bad_arg', 'basparse.py', 267), ('command -> GOSUB INTEGER', 'command', 2, 'p_command_gosub', 'basparse.py', 274), ('command -> GOSUB error', 'command', 2, 'p_command_gosub_bad', 'basparse.py', 279), ('command -> RETURN', 'command', 1, 'p_command_return', 'basparse.py', 286), ('command -> DIM dimlist', 'command', 2, 'p_command_dim', 'basparse.py', 293), ('command -> DIM error', 'command', 2, 'p_command_dim_bad', 'basparse.py', 298), ('dimlist -> dimlist COMMA dimitem', 'dimlist', 3, 'p_dimlist', 'basparse.py', 305), ('dimlist -> dimitem', 'dimlist', 1, 'p_dimlist', 'basparse.py', 306), ('dimitem -> ID LPAREN INTEGER RPAREN', 'dimitem', 4, 'p_dimitem_single', 'basparse.py', 317), ('dimitem -> ID LPAREN INTEGER COMMA INTEGER RPAREN', 'dimitem', 6, 'p_dimitem_double', 'basparse.py', 322), ('expr -> expr PLUS expr', 'expr', 3, 'p_expr_binary', 'basparse.py', 329), ('expr -> expr MINUS expr', 'expr', 3, 'p_expr_binary', 'basparse.py', 330), ('expr -> expr TIMES expr', 'expr', 3, 'p_expr_binary', 'basparse.py', 331), ('expr -> expr DIVIDE expr', 'expr', 3, 'p_expr_binary', 'basparse.py', 332), ('expr -> expr POWER expr', 'expr', 3, 'p_expr_binary', 'basparse.py', 333), ('expr -> INTEGER', 'expr', 1, 'p_expr_number', 'basparse.py', 339), ('expr -> FLOAT', 'expr', 1, 'p_expr_number', 'basparse.py', 340), ('expr -> variable', 'expr', 1, 'p_expr_variable', 'basparse.py', 345), ('expr -> LPAREN expr RPAREN', 'expr', 3, 'p_expr_group', 'basparse.py', 350), ('expr -> MINUS expr', 'expr', 2, 'p_expr_unary', 'basparse.py', 355), ('relexpr -> expr LT expr', 'relexpr', 3, 'p_relexpr', 'basparse.py', 362), ('relexpr -> expr LE expr', 'relexpr', 3, 'p_relexpr', 'basparse.py', 363), ('relexpr -> expr GT expr', 'relexpr', 3, 'p_relexpr', 'basparse.py', 364), ('relexpr -> expr GE expr', 'relexpr', 3, 'p_relexpr', 'basparse.py', 365), ('relexpr -> expr EQUALS expr', 'relexpr', 3, 'p_relexpr', 'basparse.py', 366), ('relexpr -> expr NE expr', 'relexpr', 3, 'p_relexpr', 'basparse.py', 367), ('variable -> ID', 'variable', 1, 'p_variable', 'basparse.py', 374), ('variable -> ID LPAREN expr RPAREN', 'variable', 4, 'p_variable', 'basparse.py', 375), ('variable -> ID LPAREN expr COMMA expr RPAREN', 'variable', 6, 'p_variable', 'basparse.py', 376), ('varlist -> varlist COMMA variable', 'varlist', 3, 'p_varlist', 'basparse.py', 388), ('varlist -> variable', 'varlist', 1, 'p_varlist', 'basparse.py', 389), ('numlist -> numlist COMMA number', 'numlist', 3, 'p_numlist', 'basparse.py', 400), ('numlist -> number', 'numlist', 1, 'p_numlist', 'basparse.py', 401), ('number -> INTEGER', 'number', 1, 'p_number', 'basparse.py', 413), ('number -> FLOAT', 'number', 1, 'p_number', 'basparse.py', 414), ('number -> MINUS INTEGER', 'number', 2, 'p_number_signed', 'basparse.py', 421), ('number -> MINUS FLOAT', 'number', 2, 'p_number_signed', 'basparse.py', 422), ('plist -> plist COMMA pitem', 'plist', 3, 'p_plist', 'basparse.py', 430), ('plist -> pitem', 'plist', 1, 'p_plist', 'basparse.py', 431), ('pitem -> STRING', 'pitem', 1, 'p_item_string', 'basparse.py', 440), ('pitem -> STRING expr', 'pitem', 2, 'p_item_string_expr', 'basparse.py', 445), ('pitem -> expr', 'pitem', 1, 'p_item_expr', 'basparse.py', 450), ('empty -> <empty>', 'empty', 0, 'p_empty', 'basparse.py', 457)]
#-*- coding: utf8 -*- class P3PMiddleware(object): def process_response(self, request, response): response['P3P'] = 'CP="CAO PSA OUR"' return response
class P3Pmiddleware(object): def process_response(self, request, response): response['P3P'] = 'CP="CAO PSA OUR"' return response
# Copyright 2018 Databricks, Inc. VERSION = '0.7.0.dev'
version = '0.7.0.dev'
#!/usr/bin/env python ''' This script prints Hello World! ''' print('Hello, World!')
""" This script prints Hello World! """ print('Hello, World!')
__all__ = ["InvalidECFGFormatException"] class InvalidECFGFormatException(Exception): pass
__all__ = ['InvalidECFGFormatException'] class Invalidecfgformatexception(Exception): pass
r=int(input('banyaknya angka:')) data=[] for i in range (r): #v n=int(input("Enter Integer {}:".format(i+1))) #v data.append(n) #v m=10**(r-1) for i in range (r): y=int(data[i]*m) print(y) m=m/10 #print(r);
r = int(input('banyaknya angka:')) data = [] for i in range(r): n = int(input('Enter Integer {}:'.format(i + 1))) data.append(n) m = 10 ** (r - 1) for i in range(r): y = int(data[i] * m) print(y) m = m / 10
def define_display_nodes(tree,nodemap,unscoped_vectors=False,looped_definition=False): if unscoped_vectors: s = '' else: s = '\t\t\tstd::vector<MPILib::NodeId> display_nodes;\n' display_nodes = tree.findall('.//Display') for dn in display_nodes: node_id = str(nodemap[dn.attrib['node']]) if looped_definition: node_id = str(len(nodemap))+'*i+'+node_id s += '\t\t\tdisplay_nodes.push_back('+ node_id + ');\n' s += '\n' return s def define_rate_nodes(tree, nodemap,unscoped_vectors=False,looped_definition=False): if unscoped_vectors: s = '' else: s = '\t\t\tstd::vector<MPILib::NodeId> rate_nodes;\n' s += '\t\t\tstd::vector<MPILib::Time> rate_node_intervals;\n' rate_nodes = tree.findall('.//Rate') for rn in rate_nodes: node_id = str(nodemap[rn.attrib['node']]) if looped_definition: node_id = str(len(nodemap))+'*i+'+node_id t_interval = rn.attrib['t_interval'] s += '\t\t\trate_nodes.push_back('+ node_id + ');\n' s += '\t\t\trate_node_intervals.push_back('+ t_interval + ');\n' s += '\n' return s def define_density_nodes(tree,nodemap,unscoped_vectors=False,looped_definition=False): if unscoped_vectors: s = '' else: s = '\t\t\tstd::vector<MPILib::NodeId> density_nodes;\n' s += '\t\t\tstd::vector<MPILib::Time> density_node_start_times;\n' s += '\t\t\tstd::vector<MPILib::Time> density_node_end_times;\n' s += '\t\t\tstd::vector<MPILib::Time> density_node_intervals;\n' density_nodes = tree.findall('.//Density') for dn in density_nodes: node_id = str(nodemap[dn.attrib['node']]) if looped_definition: node_id = str(len(nodemap))+'*i+'+node_id t_start = dn.attrib['t_start'] t_end = dn.attrib['t_end'] t_interval = dn.attrib['t_interval'] s += '\t\t\tdensity_nodes.push_back('+ node_id + ');\n' s += '\t\t\tdensity_node_start_times.push_back('+ t_start + ');\n' s += '\t\t\tdensity_node_end_times.push_back('+ t_end + ');\n' s += '\t\t\tdensity_node_intervals.push_back('+ t_interval + ');\n' s += '\n' return s
def define_display_nodes(tree, nodemap, unscoped_vectors=False, looped_definition=False): if unscoped_vectors: s = '' else: s = '\t\t\tstd::vector<MPILib::NodeId> display_nodes;\n' display_nodes = tree.findall('.//Display') for dn in display_nodes: node_id = str(nodemap[dn.attrib['node']]) if looped_definition: node_id = str(len(nodemap)) + '*i+' + node_id s += '\t\t\tdisplay_nodes.push_back(' + node_id + ');\n' s += '\n' return s def define_rate_nodes(tree, nodemap, unscoped_vectors=False, looped_definition=False): if unscoped_vectors: s = '' else: s = '\t\t\tstd::vector<MPILib::NodeId> rate_nodes;\n' s += '\t\t\tstd::vector<MPILib::Time> rate_node_intervals;\n' rate_nodes = tree.findall('.//Rate') for rn in rate_nodes: node_id = str(nodemap[rn.attrib['node']]) if looped_definition: node_id = str(len(nodemap)) + '*i+' + node_id t_interval = rn.attrib['t_interval'] s += '\t\t\trate_nodes.push_back(' + node_id + ');\n' s += '\t\t\trate_node_intervals.push_back(' + t_interval + ');\n' s += '\n' return s def define_density_nodes(tree, nodemap, unscoped_vectors=False, looped_definition=False): if unscoped_vectors: s = '' else: s = '\t\t\tstd::vector<MPILib::NodeId> density_nodes;\n' s += '\t\t\tstd::vector<MPILib::Time> density_node_start_times;\n' s += '\t\t\tstd::vector<MPILib::Time> density_node_end_times;\n' s += '\t\t\tstd::vector<MPILib::Time> density_node_intervals;\n' density_nodes = tree.findall('.//Density') for dn in density_nodes: node_id = str(nodemap[dn.attrib['node']]) if looped_definition: node_id = str(len(nodemap)) + '*i+' + node_id t_start = dn.attrib['t_start'] t_end = dn.attrib['t_end'] t_interval = dn.attrib['t_interval'] s += '\t\t\tdensity_nodes.push_back(' + node_id + ');\n' s += '\t\t\tdensity_node_start_times.push_back(' + t_start + ');\n' s += '\t\t\tdensity_node_end_times.push_back(' + t_end + ');\n' s += '\t\t\tdensity_node_intervals.push_back(' + t_interval + ');\n' s += '\n' return s
def factorial(n): if n==0: return 1 else: return factorial(n-1)*n print(factorial(80))
def factorial(n): if n == 0: return 1 else: return factorial(n - 1) * n print(factorial(80))
#Make sure that we handle keyword-only arguments correctly def f(a, *varargs, kw1, kw2="has-default"): pass #OK f(1, 2, 3, kw1=1) f(1, 2, kw1=1, kw2=2) #Not OK f(1, 2, 3, kw1=1, kw3=3) f(1, 2, 3, kw3=3) #ODASA-5897 def analyze_member_access(msg, *, original, override, chk: 'default' = None): pass def ok(): return analyze_member_access(msg, original=original, chk=chk) def bad(): return analyze_member_access(msg, original, chk=chk)
def f(a, *varargs, kw1, kw2='has-default'): pass f(1, 2, 3, kw1=1) f(1, 2, kw1=1, kw2=2) f(1, 2, 3, kw1=1, kw3=3) f(1, 2, 3, kw3=3) def analyze_member_access(msg, *, original, override, chk: 'default'=None): pass def ok(): return analyze_member_access(msg, original=original, chk=chk) def bad(): return analyze_member_access(msg, original, chk=chk)
class Parser(): def __init__(self, config): self._config_args = config @property def experiment_args(self): return self._config_args["Experiment"] @property def train_dataset_args(self): return self._config_args["Dataset - metatrain"] @property def valid_dataset_args(self): return self._config_args["Dataset - metatest"] @property def model_args(self): return self._config_args["Model"] @property def maml_args(self): return self._config_args["MAML"] @property def training_args(self): return self._config_args["training"] def parse(self): return self.experiment_args, self.train_dataset_args, self.valid_dataset_args, self.model_args, self.maml_args, self.training_args
class Parser: def __init__(self, config): self._config_args = config @property def experiment_args(self): return self._config_args['Experiment'] @property def train_dataset_args(self): return self._config_args['Dataset - metatrain'] @property def valid_dataset_args(self): return self._config_args['Dataset - metatest'] @property def model_args(self): return self._config_args['Model'] @property def maml_args(self): return self._config_args['MAML'] @property def training_args(self): return self._config_args['training'] def parse(self): return (self.experiment_args, self.train_dataset_args, self.valid_dataset_args, self.model_args, self.maml_args, self.training_args)
class X: def __init__(self,x): print("Inside X ", x) class Y: def __init__(self): print("Inside Y") class Z(X,Y): def __init__(self): super().__init__(10) print("Inside Z") obj = Z()
class X: def __init__(self, x): print('Inside X ', x) class Y: def __init__(self): print('Inside Y') class Z(X, Y): def __init__(self): super().__init__(10) print('Inside Z') obj = z()
# -*- coding: utf-8 -*- valor = float(input()) if 0 < valor <= 25: print('Intervalo [0, 25]') elif 25 < valor <= 50: print('Intervalo (25, 50]') elif 50 < valor <= 75: print('Intervalo (50, 75]') elif 75 < valor <= 100: print('Intervalo (75, 100]') else: print('Fora de intervalo')
valor = float(input()) if 0 < valor <= 25: print('Intervalo [0, 25]') elif 25 < valor <= 50: print('Intervalo (25, 50]') elif 50 < valor <= 75: print('Intervalo (50, 75]') elif 75 < valor <= 100: print('Intervalo (75, 100]') else: print('Fora de intervalo')
# Aula 13 - Desafio 47: Contagem de numeros pares # Mostrar na tela todos os numeros pares entre 1 e 50 print('Entre 1 e 50, sao numeros pares:') for n in range(2, 51, 2): print(n, end=' ')
print('Entre 1 e 50, sao numeros pares:') for n in range(2, 51, 2): print(n, end=' ')
word1=input() word2=input() dict={} alphabet="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" for char in alphabet: dict[char]=0 for ch in word1: dict[ch]+=1 for ch in word2: dict[ch]-=1 flag=False sum=0 for char in dict: count=dict[char] sum+=count if count == 1: flag=True if flag and count>1: flag=False break if flag and sum==0: print("Yes") else: print("No")
word1 = input() word2 = input() dict = {} alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' for char in alphabet: dict[char] = 0 for ch in word1: dict[ch] += 1 for ch in word2: dict[ch] -= 1 flag = False sum = 0 for char in dict: count = dict[char] sum += count if count == 1: flag = True if flag and count > 1: flag = False break if flag and sum == 0: print('Yes') else: print('No')
#!/usr/bin/env python # -*- coding: utf-8 -*- # Source code meta data __author__ = 'Dalwar Hossain' __email__ = 'dalwar.hossain@protonmail.com'
__author__ = 'Dalwar Hossain' __email__ = 'dalwar.hossain@protonmail.com'
tm20 = toi = h = 0 print('-' * 25) print(' CADASTRANDO PESSOAS ') print('-' * 25) while True: id = int(input('digite a idade ')) sex = ' ' while sex not in 'MF': sex = str(input('digite o sexo')).upper() if id >= 18: toi += 1 if sex == 'M': h += 1 if sex == 'f' and id < 18: tm20 += 1 r = ' ' while r not in "SN": r = str(input('quer continuar?[s/n]')).upper() if r == 'N': break print(f' {toi} pessoas tem mais de 18 anos') print(f'o total de homens foi {h}') print(f'total de mulheres com menos de 20 anos {tm20}')
tm20 = toi = h = 0 print('-' * 25) print(' CADASTRANDO PESSOAS ') print('-' * 25) while True: id = int(input('digite a idade ')) sex = ' ' while sex not in 'MF': sex = str(input('digite o sexo')).upper() if id >= 18: toi += 1 if sex == 'M': h += 1 if sex == 'f' and id < 18: tm20 += 1 r = ' ' while r not in 'SN': r = str(input('quer continuar?[s/n]')).upper() if r == 'N': break print(f' {toi} pessoas tem mais de 18 anos') print(f'o total de homens foi {h}') print(f'total de mulheres com menos de 20 anos {tm20}')
# De uitwerking van 4-autoencoder.py moet hiervoor gedraaid worden! voorspeller = tf.keras.models.Sequential([ tf.keras.layers.Dense(200, activation=tf.nn.relu), tf.keras.layers.Dense(50, activation=tf.nn.relu), tf.keras.layers.Dense(50, activation=tf.nn.relu), tf.keras.layers.Dense(10, activation=tf.nn.softmax) ]) voorspeller.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy']) voorspeller.fit(xtr, ytr, epochs=10) print(voorspeller.evaluate(xtr, ytr)) print("Performance op ruizige getallen:") print(voorspeller.evaluate(xruis, y)) print("Performance van hetzelfde netwerk op door auto-encoder gereconstrueerde getallen:") print(voorspeller.evaluate(reconstructed, y)) print("Als het goed is, flinke winst!")
voorspeller = tf.keras.models.Sequential([tf.keras.layers.Dense(200, activation=tf.nn.relu), tf.keras.layers.Dense(50, activation=tf.nn.relu), tf.keras.layers.Dense(50, activation=tf.nn.relu), tf.keras.layers.Dense(10, activation=tf.nn.softmax)]) voorspeller.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy']) voorspeller.fit(xtr, ytr, epochs=10) print(voorspeller.evaluate(xtr, ytr)) print('Performance op ruizige getallen:') print(voorspeller.evaluate(xruis, y)) print('Performance van hetzelfde netwerk op door auto-encoder gereconstrueerde getallen:') print(voorspeller.evaluate(reconstructed, y)) print('Als het goed is, flinke winst!')
# model settings model = dict( type='ImageClassifier', pretrained=None, backbone=dict( type='OmzBackboneCls', mode='train', model_path='public/mobilenet-v2/FP32/mobilenet-v2.xml', last_layer_name='relu6_4', normalized_img_input=True ), neck=dict( type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, in_channels=1280, loss=dict(type='CrossEntropyLoss', loss_weight=1.0), ))
model = dict(type='ImageClassifier', pretrained=None, backbone=dict(type='OmzBackboneCls', mode='train', model_path='public/mobilenet-v2/FP32/mobilenet-v2.xml', last_layer_name='relu6_4', normalized_img_input=True), neck=dict(type='GlobalAveragePooling'), head=dict(type='LinearClsHead', num_classes=1000, in_channels=1280, loss=dict(type='CrossEntropyLoss', loss_weight=1.0)))
class Environment(object): def __init__(self): pass def act(self, state, action): pass def end_state(self, state): return True def reset(self): pass def available_actions(self): return None
class Environment(object): def __init__(self): pass def act(self, state, action): pass def end_state(self, state): return True def reset(self): pass def available_actions(self): return None
# Question(#1143): Given two strings text1 and text2, return the length of their longest common subsequence. # Solution: Use the longest common susequence dynamic programming algorithm def longestCommonSubsequence(text1: str, text2: str) -> int: grid = [[0 for _ in range(len(text2)+1)] for _ in range(len(text1)+1)] for i in range(1, len(text1)+1): for j in range(1, len(text2)+1): if text1[i-1] == text2[j-1]: grid[i][j] = 1 + grid[i-1][j-1] else: grid[i][j] = max(grid[i][j-1], grid[i-1][j]) return grid[-1][-1]
def longest_common_subsequence(text1: str, text2: str) -> int: grid = [[0 for _ in range(len(text2) + 1)] for _ in range(len(text1) + 1)] for i in range(1, len(text1) + 1): for j in range(1, len(text2) + 1): if text1[i - 1] == text2[j - 1]: grid[i][j] = 1 + grid[i - 1][j - 1] else: grid[i][j] = max(grid[i][j - 1], grid[i - 1][j]) return grid[-1][-1]
print("Let's do Factorial") #printing the operation what we are performing def factorial(number): #defining the factorial method result = 1 # result is intially defined with 1. if we define initially with 0 the factorial will be 0. if number == 0: # if number is equals to 0, it prints 1. print("The factorial of 0 is 1") elif number < 0: # if number is negative number , it prints error message print("Error..Enter only whole numbers") else: for i in range(1, number+1): # we are using range function for multiplication of numbers result = result * i # multiplication of numbers is factorial. result is stored in result variable print("The Factorial of" ,number, "is : ", result) # result will be printed number = int(input("Enter the number: ")) # Input is taken from user factorial(number) # Function is called
print("Let's do Factorial") def factorial(number): result = 1 if number == 0: print('The factorial of 0 is 1') elif number < 0: print('Error..Enter only whole numbers') else: for i in range(1, number + 1): result = result * i print('The Factorial of', number, 'is : ', result) number = int(input('Enter the number: ')) factorial(number)
#!/usr/bin/env python include = "$chrs".replace("[", "").replace("]", "").replace(" ", "").split(",") ref = "$reference" with open(ref) as ifh, open("include.bed", "w") as ofh: for line in ifh: toks = line.strip().split("\\t") if toks[0] in include: print(toks[0], 0, toks[1], sep="\\t", file=ofh)
include = '$chrs'.replace('[', '').replace(']', '').replace(' ', '').split(',') ref = '$reference' with open(ref) as ifh, open('include.bed', 'w') as ofh: for line in ifh: toks = line.strip().split('\\t') if toks[0] in include: print(toks[0], 0, toks[1], sep='\\t', file=ofh)
# Modify the program to show the numbers from 50 to 100 x=50 while x<=100: print(x) x=x+1
x = 50 while x <= 100: print(x) x = x + 1