Python doubt jason

  1. sir explain this problem - Python If-Else | HackerRank

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): = 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 }

Basically you have to creat a dictionary in python where keys will be name, engine and price and value will be their respective values.

and then you can dump this dictionary into a json file

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, .


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:


[mam for this question he solved such type of format can you explain me how he solved it ]


He uses a .dump() in built function which is used to convert dictionary to jason