Geo Location 1
title: "Geo Location 1"
author: "Rj"
date: 2019-04-20
description: "-"
type: technical_note
draft: false
import requests
import json
send_url = 'http://api.ipstack.com/50.100.30.136?access_key=49ad529d309a09477749245782d260b8&format=1'
r = requests.get(send_url)
j = json.loads(r.text)
lat = j['latitude']
lon = j['longitude']
Read More
Get Attribute
title: "Get Attribute"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
print(getattr(sys, 'version'))
3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
Score: 0
Read More
Get Int Input
title: "Get Int Input"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
x = int(input("Enter a number: "))
y = int(input("Enter a number: "))
print((x+y))
Enter a number: one
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-d1355a0ae898> in <module>()
----> 1 x = int(input …
Read More
Get-Value-And-Check-1
DATA = "data"
JSON_DATA = "jsonData"
PENALIZATION_IMPUTATION_WEIGHTAGE = "penalizationImputationWeightage"
mltrainconfig_json = {
"data" : {
"jsonData" : {
"penalizationImputationWeightage" : {
"one" : "two"
}
}
}
}
penalization_imputation_weightage = mltrainconfig_json.get(DATA, {})\
.get(JSON_DATA, {})\
.get(PENALIZATION_IMPUTATION_WEIGHTAGE, {})
penalization_imputation_weightage = penalization_imputation_weightage if penalization_imputation_weightage else imputing_factor_value
penalization_imputation_weightage
mltrainconfig_json = {
"data" : {
"jsonData" : {
"penalizationImputationWeightage2" : {
"one" : "two"
}
}
}
}
imputing_factor_value = {
"eleven" : "twelve"
}
penalization_imputation_weightage = mltrainconfig_json.get(DATA, {})\
.get(JSON_DATA, {})\
.get(PENALIZATION_IMPUTATION_WEIGHTAGE, {})
penalization_imputation_weightage
penalization_imputation_weightage = penalization_imputation_weightage if …
Read More
Immutable-Int
title: "Immutable Int"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
a = 12
dictionary = {
"one": a
}
int is immutable, that's why you can't see the dictionary value changed
Here you are assigning to key 'a' …
Read More
Index Remover
"""
input sample:
17. random text1
18. random text2
output:
17, random text1
18, random text2
"""
'\ninput sample:\n17. random text1\n18. random text2\n\noutput:\n17, random text1\n18, random text2\n'
input_sample = """
17. random text1
18. random text2
"""
# Process the input sample
output = []
for line in input_sample.strip().split …
Read More