CLASS class car: def __init__ ( self , name , speed , mileage , ): self .name = name self .speed = speed self .mileage = mileage NOW from car import car car = car( "kia" , "66" , "10" ) print (car.mileage) OUTPUT: 10
Posts
Showing posts from March, 2022
- Get link
- X
- Other Apps
CLASSES AND OBJECT class Student: def __init__ ( self , name , major , gpa , is_on_probation): self .name = name self .major = major self .gpa = gpa self .is_on_probation = is_on_probation IN APP.PY FILE from Student import Student student1 = Student( 'Utkarsh' , "Business" , 9.9 , False ) print (student1.name) OUTPUT= utkarsh
- Get link
- X
- Other Apps
APP USING FILE import random feet_in_mile = 500 meters_in_kilometers = 1000 beatles = [ "John Lennon" , "Paul McCartney" , "George Harrison" , "Ringo Star" ] def get_file_ext (filename): return filename[filename.index( "." ) + 1 :] def roll_dice (num): return random.randint( 1 , num) IN useful_tools files import useful_tools print (useful_tools.roll_dice( 10 ))
- Get link
- X
- Other Apps
CALCULATOR😎 num1= float ( input ( "enter the first number" )) op= input ( "enter the operator" ) num2= float ( input ( "enter the second number" )) if op == "+" : print (num1 + num2) elif op == "-" : print (num1 - num2) elif op == "/" : print (num1 / num) elif op == "*" : print (num1 * num2) else : print ( "invalid character" )