2)x = {“id” : 1, “name” : “value2”, “age” : 29,“value3”:“shyam”}
[if i want to sort this json in such type how can i change it ]—{“name” : “value2”, “id” : 1, “age” : 29,“value3”:“shyam”}
3)import json
class Vehicle:
def init(self, name, engine, price):
self.name = name
self.engine = engine
self.price = price
vehicle = Vehicle(“Toyota Rav4”, “2.5L”, 32000)
if i want to convert it json key value pair how can i convert it
like—{ “name”: “Toyota Rav4”, “engine”: “2.5L”, “price”: 32000 }
HACKER-RANK PROBLEM Task
Given an integer, , perform the following conditional actions:
If is odd, print Weird
If is even and in the inclusive range of 2 to 5 , print Not Weird
If is even and in the inclusive range 6 of to 20 , print Weird
If is even and greater than 20, print Not Weird
Input Format
A single line containing a positive integer, .
Constraints
1<=N<=100
So Basically you need to understand the problem statement , you just need to use if elif ladder put the different conditions there, and the print statements,
for e.g
if n>=1 and n<=100:
if n%2=0:
if (n>=2 and n<=5) or n>=20:
print(" not weird")
elif n>=6 and n<=20:
print(“weird”)