Raising custom errors in Python | Python Tutorial - Day #38
ฝัง
- เผยแพร่เมื่อ 20 ก.ย. 2024
- Python is one of the most demanded programming languages in the job market. Surprisingly, it is equally easy to learn and master Python. This python tutorial for absolute beginners in Hindi series will focus on teaching you python concepts from the ground up.
Access the Playlist: • Python for Beginners (...
Link to the Repl: replit.com/@co...
Join Replit the browser-based IDE used in this course - join.replit.co...
►Checkout my English channel here: / @programmingwithharry
►Instagram: codewithharry
python, C, C++, Java, JavaScript and Other Cheetsheets [++]:
Playlist: • Coding CheatSheets 🧾 b...
►Learn in One Video[++]:
Python[15 Hr]: • Python Tutorial For Be...
Python Advance[3.5 Hr]: • Python Programming Cou...
Python[1 Hr]: • Learn Python In Hindi ...
Python[2 Hr]: • Python Tutorial In Hin...
Python[15 Min]: • 15 Minute Python Tutor...
JavaScript[1 Hr]: • JavaScript Tutorial
C[1.3 Hr]- • C Programming Tutorial...
php[1 Hr]: • Learn Php In One Video...
php[2.3 Hr]: • Php Tutorial for Begin...
php[Project]- • Login And Registration...
HTML[30 Min]: • HTML 5 Tutorial For Be...
CSS[8.5 Hr]: • CSS Tutorial In Hindi ...
CSS[1.4 Hr]: • CSS 3 Tutorial For Beg...
Wordpress[3.2 Hr]: • How To Make a WordPres...
Angular[2 Hr]: • Angular Tutorial in Hindi
Java[2.3 Hr]: • Java tutorial in hindi 🔥
Web Scraping[1 Hr]: • Web Scraping Tutorial ...
MongoDB[2 Hr]: • MongoDb Tutorial For B...
Numpy[1 Hr]: • Numpy Tutorial in Hindi
Android Dev[12 Hr]- • Android Development Tu...
Linux[1 Hr]: • Linux Tutorial For Beg...
JQuery[1.1 Hr]: • jQuery Tutorial For Be...
Git and GitHub[1.1 Hr]: • Git & GitHub Tutorial ...
►Complete course [playlist]:
React: • React Js Tutorials in ...
Python- • Python Tutorials For A...
OOP Python- • Object Oriented Progra...
Java: • Java Tutorials For Beg...
JavaScript- • JavaScript Tutorials I...
PHP- • PHP Tutorials in Hindi
C- • C Language Tutorials I...
C++- • C++ Tutorials In Hindi
Git & GitHub- • Git and GitHub Tutoria...
Android Dev- • Android Development Tu...
Python GUI- • Python GUI: Tkinter Tu...
Web Development- • Web Development Tutori...
Python Django: • Python Django Tutorial...
Projects Using HTML, CSS & Javascript- • Projects Using HTML, C...
Data Structure and Algo: • Data Structures and Al...
Follow Me On Social Media
►Website (created using Django Rest & Angular): www.codewithha...
►Facebook: / codewithharry
►Instagram: / codewithharry
Twitter: / codewithharry
Comment "#HarryBhai" if you read this 😉😉
This python course is helpful than all of those courses for paid!
Jabardast Harry Bhai!
Yes 👍👍
a = input("Enter the value butween 5 and 9: ")
if (a == "quit"):
print("ohk")
elif (int(a) < 5 or int(a) > 9):
raise ValueError("The number should be between 5 and 9")
Ye kaisa hai code hai run karke dekha kya
a=input("enter any number between 5-10 : ")
if a=="quit":
quit()
a=int(a)
if (a10):
raise ValueError("u not entered vallide number")
else:
print(a)
a = input("Enter the string only QUIET")
if(a!="QUIET"):
raise ValueError ("value Should be between 6 and 9")@@hnxpriyanshu
@@marialor2744 😂😂😅
@@hnxpriyanshu 🤣🤣🤣🤣
a=input('Enter a number between 5 and 9: ')
if (a=='quit'):
exit()
elif a.isalpha():
print('Enter an integer value')
elif ((int(a)9) ):
raise ValueError('Entered value is not in between 5 or 9')
elif((int(a)>=5) or (int(a)
great
It will show built-inerror when I type company12 as input
Replacing the last elif statement with else: would provide the same result.
a = input("enter number between 5-9 or enter quit for exit")
if(a == "quit"):
exit()
elif(int(a) 9:
raise ValueError(" You entered wrong input")
a = input("Enter any value between 5 and 9: ")
try:
if (int(a)9):
raise ValueError("Value should be between 5 and 9")
except:
if a == str(a) and a !="quit":
raise ValueError("Value should be between 5 and 9")
print("code ended successfuly")
Input value ko apne string me convert kiya uski jarurat nahi thi bro 🙌
it's wrong. If you enter 2 or any other num, error won't be generated
a=input("Enter any value: "
If(a == quit):
raise ValueError("Error 404")
Quick Quizz Question ->
User = input("Enter The Value Between 5 And 9 : ")
try:
if (User == "Quit"):
print("Better Luck Next Time!")
else:
if (int(User)>= 5 and int(User)
@@zameerkhan1306 Correct Hain lakin Yeh Quick Quizz Ka solution nahi hain yeh.
Agar Mein "quit" likhte hu toh vo print kr jayega lakin agar mein koi integer pass krwata hu toh valueerror aa jayega
a=input("Enter Please")
if a=='quit' or a== 'Quit':
print("Yes")
elif a.isnumeric():
raise ValueError("Sorry enter quit")
for i in range(6):
a = input("Please enter value between 5 to 9: ")
try:
if (a == "quit"):
print("Comeback soon")
elif (int(a) >= 5 and int(a)
a = input("Enter the value between 5 and 9 : ")
if(a == "quite"):
print("Thank You")
elif(int(a)9):
raise ValueError("The given item is invalid")
print("Thank You
Have a Great Day")
100% true 😊
a = input("Enter any value between 5 and 9 : ")
if a == "quit":
print("you choosed to quit")
elif (int(a) < 5 or int(a) > 9):
raise ValueError("Value should be between 5 and 9")
but if i type any other string , there is another error that is you converted a string into integer in elif statement
@@arnabgoswami-bj6cl
inpt = input("Enter an integer(between 5 and 9) : ")
try :
if inpt == "quit":
print("no error")
elif 5 < int(inpt) < 9:
print(f"{inpt}")
elif int(inpt) < 5 or int(inpt) > 9:
raise ValueError("Sahi value daal bhai")
except :
print(f"please enter the either \"quit\" or the value between 5 and 9")
😁😁😁😁😂@@azimshaikh179
that sahi daal bhaii was personal 🤣
@@azimshaikh179I think in the 5th line, if you wrote
elif 5 < int(float(inpt)) < 9:
This will efficiently type cast.
a = input('enter any value between 5 and 10')
if a == 'quit':
print('no error ')
elif 5 < a < 10:
print('number are between 5 and 10')
else:
raise ValueError('value should be between 5 and 10')
a = input("Enter any value between 5 and 9. Write 'quit' to quit:")
def myfuc():
if a=="quit":
print("program quitted")
else:
if(int(a)9):
raise ValueError("Value should be between 5 and 9")
else:
print(a)
myfuc()
a=input('Enter the value between 5 and9'l
If(a==quit):
Print("ohk");
Elif("int (a)>=5or(int(a)
a=input("Enter the value beetween 0 and 9 or quit for exit - ")
string=str(a)
for i in range(0,10):
if a=="quit":
break
elif a!= "quit":
a=int(a)
if (a9):
raise ValueError("the Value should be in 0 to 9")
else:
print(a)
we dont want same output 10 times
Here it is Sir:
def run():
user_input = input("Enter Value Between 5 and 9: ")
try:
if(user_input=='quite'):
print('I am quite')
elif(5>int(user_input)
this code is wrong :aise ValueError("Value must be 5>user_input)>9")
there is no such no. thats less than 5 and greater than 9
this code in entirety is wrong
x=input("enter:")
if(x.isnumeric()) :
if(not 5
a = input("enter any value")
if a == str("viru"):
print("sorry")
else:
try:
if int(a) < 4 or int(a) > 9:
print("enter a value between 4 and 9")
elif int(a) >4 and int(a) < 9:
print(a)
except:
print("sorry!")
wrong..quit kaha pr hai
a=input("enter b/w 5 and 9 or enter 'quit'")
if(str(a)=='quit'):
print(a)
elif(5
a = input("enter a number between 5 and 9 : ")
if a == "quit" :
print("you chose to quit")
elif int(a)9:
raise ValueError("Number out of range.")
elif int(a)>5 or int(a)
a= input("Enter a word")
class CustomError(Exception):
print("This is custom error")
if(a=="quit"):
print ("This word is \'quit\' ")
else:
raise CustomError("Word is unmatch")
bhai class nhi padhai yrr abhi but code sahi hai ig
@@gtaburn7397 run kar k check kia..ye agr quit bhi likhey phir bhi custom error dey raha
print("here we make errors by ownself".upper())
k1=input("enter the num between 5 and 9 , write quite
")
if int(k1)>5 or int(k1)
i = input("Enter value betwwen 1 and 4: ")
if i == "quit": #treat this as a try
print("OK, program quited")
elif int(i)>4 or int(i)
a = input("Enter any value between 5 and 9: ")
if (a == "quit"):
print("you quitted")
exit()
if (int(a)9):
raise ValueError("value should be between 5 and 9")
else:
print("thanks for your input")
a=input("enter a no.between 1 to 9")
try:
if int(a)>9 or int(a)
This code is not correct
alpha = input("enter the word quit :").lower()
try:
if alpha =="quit":
print("you are all good")
else:
raise ValueError('value need to be only quit')
except ValueError as er:
print(er)
a = input("Enter num: ")
try:
if (int(a) < 0 or int (a)>5):
raise ValueError("Enter valid input!")
except:
if (a!="quit"):
raise ValueError("Enter valid input!")
print("End")
I'm late but tried my code and sucessfully executed
why did u write ! after a in if (a!="quit"):
It means "not equal to"@@dabilover444
a=input("Enter value : ")
if a== "quit":
print("Executed")
elif a!="quit":
raise ValueError ("U enter wrong value")
a = input( " Enter any value between 5 and 9: ")
if a == "quit":
print("quitting program")
exit()
elif a < "5" or a > "9":
raise ValueError( "Value should be between 5 and 9")
a=input("Enter any value between 5 and 9 : ")
try:
if(a=='quit'):
print("you have quitted")
elif (int(a)9):
raise ValueError("Please enter value between 5 and 9.")
else:
print("You're good to go.")
except Exception as e:
print(f"Error is : {e}")
Please make a video on freelancing
a = input("Enter a number:")
if a == "quite":
print("Program is quite")
elif(int(a)9):
raise ValueError("Value should be between 5 and 9")
else:
print("you choose the right number", a)
a=(input("Enter a number between 3 and 8: "))
try:
if a=="quit":
print("str done")
elif int(a)3:
print("int done")
except:
raise ValueError("Invalid input")
a = input("Enter a number between 5 and 20: ")
if a == 'quit':
print("Program broken!")
elif int(a)20:
raise ValueError("The number should be greater than 5 and less than 20!")
else:
for i in range(1, 11):
print(f"{int(a)}x{i}={int(a)*i}")
a = input("Enter any value between 5 and 9")
if (a=='quit'):
print("this program is passed")
else:
(int(a)9 )
raise ValueError("Value should be between 5 and 9")
a=input("enter a number between 5 and 9")
try:
if(a=="quit"):
print("Input successfully recieved")
elif(5>int(a)) or (int(a)>9):
raise ValueError("invalid input")
else:
print("Input successfully recieved")
except:
print(f"please enter the either \"quit\" or the value between 5 and 9")
a = input("Enter any value between 5 and 9")
if a.isnumeric():
if int(a) < 5 or int(a) > 9:
raise ValueError("Value should be between 5 and 9")
elif a.isalpha():
if a.lower() == "quit":
print("Program ended")
else:
raise TypeError("Enter correct datatype")
a = input("Enter the value: ")
if a == "quit":
print()
elif int(a)>5 and int(a)
av = input("enter the value between 5 and 10 (to quite write quit:) : ")
if av.lower() == 'quit':
print("you are quitting...........")
else:
try:
a = int(av)
if (a < 5 or a > 10):
raise ValueError("please enter the value should be between 5 and 10")
except ValueError as e:
print(e)
else:
print(a)
i = 1
while(i==1):
i+=1
a = (input("Enter any value between 5 and 9 : "))
if a == "ij roy":
print("You are a good boy")
break
a = int(a)
if(a9):
raise ValueError("Value should be between 5 and 9")
print(f"You entered {a}")
a=input("Enter any nymber btw 3 to 9: ")
if(a=="quit"):
print(" ")
try:
if(int(a)>9 or int(a)
print("
")
i = input("Write Here : ")
if i == "quit":
print("Successfully Quit")
else:
if (int(i) < 10 or int(i) > 20):
raise ValueError("Value should be between 10 and 20")
THANK YOU FOR THIS AMAZING QUIZ 😍😍😄😄 ❤❤
a = input("Enter any value between 5 and 9 or \"quit\": ")
if a == "quit":
print("Thank you!")
elif a.isalpha():
raise ValueError("Invalid input! Value should be between 5 and 9")
else:
a = int(a)
if 5
while True:
input_ = input("enter a number between 7 and 15 (enter q or quit): ").lower()
if input_ == "q" or input_ == "quit":
print("thank you")
break
try:
num = int(input_)
if 7
can you explain me that how the again and again play game function is working if we print yes in last....how he knows that yes mean start the function again...kindly reply
@@Nothing-78646 because of the while true part
while True:
input_ = input("enter a number between 7 and 15 (enter q or quit): ").lower()
if input_ == "q" or input_ == "quit":
print("thank you")
break
try:
num = int(input_)
if num < 7 or num > 15:
raise ValueError("the number should be between 7 and 15")
print(f"the answer is {num}")
except ValueError as e:
print(e)
except TypeError:
print("you entered an invalid string")
finally:
play_again = input("Do you want to play again? (yes/no): ").lower()
if play_again != "yes":
print("Thank you for playing.")
break
print("Let's play again!
")
a=input('enter integer ')
if (a=='quit'):
print('yes, you quit this programme')
elif(int(a)9) :
raise ValueError("you must enter 5-9 integer ")
else:
print('done, value accepted 😊')
Harry sir i have tried this one:
a = (input("Enter any value between 5 and 9 : "))
if(a=="quit"):
print("User has quit the program")
elif(str(5)
use and*
str(5) < a and a < str(9)
a=input("enter a number between 5 and 9")
if a=="quit":
print("ok")
elif(a.isalpha()==True):
raise TypeError("Its not a integer literal")
elif(int(a)>5 and int(a)
a = (input('Value between 5 and 9 : (or type "quit" to exit): '))
if(a.lower()=='quit'):
print('Program Quit')
elif(int(a)9):
raise ValueError('Value should be between 5 and 9')
else:
print('Value is : ',a ,'Thanks for correct input')
a = input ("Enter any number value between 5 and 9 or enter quit
>>")
try:
if (int(a)9):
raise ValueError("The number is either lesser than 5 or bigger than 9")
except:
if a!= "quit":
raise ValueError ("You entered a string other than quit")
noooooooooooooooooooooooooooo
👍
Bro ek baat input me out of range no. Dal ke dekho error except ka aayaga
bro ,,, if (int(a)9) ,,, isme or operator use hoga
a=input("enter a number btw 5 to 9:-")
if (a.lower()=="quit"):
print("you quit!!")
elif (5
a=input("Enter the value btwn 5 and 9- ")
try:
if a.lower()=="quit":
print("Program ends here")
else:
if int(a)>5 and int(a)
a = input("Enter any value between 5 and 9 or quit")
if a == "quit":
print("quitted")
elif a == "6" or a == "7" or a == "8":
int(a)
print(f"it's {a}")
else:
raise ValueError(
"it's an invalid value please enter value between 5 and 9 or quit")
print("Enter any value between 5 and 9: ",end = '')
a = input()
if(a == "quit"):
pass
elif(int(a) < 5 or int(a) > 9):
raise ValueError("Value out of bounds !!!")
a=(input("Enter any value between 5 and 9: "))
if (a=="quit"):
print("You chose to quit!")
elif(int(a)9):
raise ValueError("You entered the name out of range.")
else:
print(a)
a = input("enter the value between 5 and 9:")
if (a.lower()=="quit"):
print(a.lower())
elif(int(a)9):
raise ValueError("value should be between 5 and 9")
else:
print(a)
a=(input("enter your answer:"))
if(a=="quit"):
print("quit")
elif(int(a)10):
raise ValueError("value error")
this will show an error
a = input("Kindly enter an integral value between 5 and 10: ")
if a == "quit":
print("
No problem. Thanks for you time.")
else:
if (int(a)>9 or int(a)
Do you try Raghav as a string it must be raise error if any string other than the quite is enter
while True:
a = input("Enter the value butween 5 and 9: ")
if (a == "quit"):
print("ohk")
break
elif (int(a)>=5 and int(a) 9:
raise ValueError("The value should be between 5 and 9")
print(f"The number {num} is within the range.")
except ValueError as e:
print(e)
a = input("Enter any value between 5 and 9")
try:
if (int(a)9):
raise ValueError("Value should be between 5 and 9")
except:
if(a=="quit"):
print("quit")
elif type(a)==str:
raise TypeError("Value should be an integer")
print(f"your entered no {a} has been accepted")
perfect code under this quick quiz:-
a=input("enter a no. between 5 and 9:")
try:
if a=="quit":
print("No error")
quit()
elif a.isalpha():
raise ValueError("Please enter a no not a string")
b=int(a)
if b9:
raise ValueError("No should be between 5 and 9")
except Exception as e:
print(e)
a=input("Enter a number:
")
if a=="quit":
print("NO ERROR")
exit()
elif(a.isalpha()):
print("Enter an integer")
elif(int(a)9):
raise ValueError("Enter number between 5 and 9")
else:
print(("Entered number is between 5 and 9"))
a=input("Enter value between 5 to 9: ")
if (a == "quit"):
print("you Quit")
elif(int(a)9):
raise ValueError("Value is not between 5 to 9")
else:
print(a)
a = (input("enter value between 5 and 9 or enter quit"))
if a == "quit" :
print()
elif (a9 ):
raise ValueError("Value is should be between 5 and 9 or quit)
a=(input("Enter the value between 1 to 11"))
if(a==int()):
if(int(a)int(11)):
raise inputerror("Input should be between 1 to 11.")
elif(a=="quite"):
print("Exiting the program")
else:
print("The input is :",a)
# raising custom error in case of any problem
def error(in):
if(in =="quit"):
print(f"ok I am {in}")
elif(in9):
raise ValueError("value should be between 5 and 9")
return 1
i = input("enter the choice")
error(i)
love you harry bhai
a=input(("enter the value between 5 and 9
"))
try:
a=int(a)
if(a9):
raise ValueError("value should be between 5 and 9")
except Exception:
if a=="quit":
pass
elif a!="quit":
print("value should be between 5 and 9")
print("end of program")
X= input("enter the quit string ")
For i in quit :
If i ==Q :
Break
Raise Valueerror("you have entered capital Letter ")
Jani jab condition he true nai to loop break kaysa ho ga??
a = input("Enter the number you want:")
try:
if a == "quit":
print("The only string which is valid")
print(a)
elif int(a) < 5 or int(a) > 9:
raise ValueError("The value doesn't suit the given expected range")
except ValueError as e:
print(e)
wrong try lol as input your programme will fail
x=input("enter:")
if(x.isnumeric()) :
if(not 5
@@vatsalsharma4061 copy and run it first
@@vatsalsharma4061a = input("Enter the number you want:")
try:
if a == "quit":
print("The only string which is valid")
print(a)
elif int(a) < 5 or int(a) > 9:
raise ValueError()
except ValueError as e:
print("Error",e)
@@__idyllist ok right
a=input("enter QUIT in small letters: ")
d="quit"
if (a==d):
print("ok")
else:
raise valuerror("please check the input")
a = input("Enter a number: ")
try:
if(a == "quite"):
print("quiting the programme")
elif(int(a)>5 and int(a)
quick quiz solution :-
n=input("Enter number between 5 to 10 : ")
if(n=="quite"):
print("quite")
elif(int(n)>10 or int(n)
a = (input("Enter the num between 5 and 9: "))
if (a =="quit"):
exit()
a = int(a)
if (a9):
raise ValueError("you not entered valid number")
else:
print(a)
date : 20-09-2024
a=(input("Enter any value between 5 & 9: "))
if(a=="quit"):
print("dalal")
elif(int(a)9):
raise ValueError("BKL 5 or 9 ke beech me daal")
a = input('enter number b/w 5 and 9 ')
if a == 'quit':
print('ok')
else:
a = int(a)
if (a9):
raise ValueError('number should be between 5 and 9')
else:
print('restart')
a=(input("Enter a number between 5 and 9:"))
if( a=='quite'):
print("right input!")
elif(a'9'):
raise ValueError("Invalid Inputs!")
else:
print("Do nothing")
a =(input("Enter your number : "))
if ("quit") in a:
print("Program has been ended!")
elif(int(a)>3 and int(a)
11.09.2024 day 38 is done.
a = input("Enter any value between 5 and 9")
if(a == "quit"):
print("no error")
elif 5 < int(a) < 9:
print("nuber are between 5 and 9")
else:
raise ValueError("Value should be between 5 and 9")
try:
a=(input("enter the value of a"))
if a == "quit":
print('you choosed to quit')
elif int(a)9:
print("you have entered an correct number")
except:
print("some error has occured")
a = input("Enter bw 5 and 9: ").lower()
if a == "quit":
print("Quitting...")
elif a.isdigit():
if (int(a)9):
raise ValueError("Should be between 5 and 9")
else:
print("You are good to go!")
else:
raise ValueError("Only quit is acceptable!")
with custom exception name
class stringerror(Exception):
pass
word = input("Type any word : ")
def string_check(word):
required = "quit"
index = word.find(required)
if index == 0 and word.islower():
print (f"Congrats !! This is correct {word} you have entered")
else:
raise stringerror ("Try to enter the required quit in smaller case")
string_check(word)
a = str(input("Enter any value between 5 and 9"))
if((a'9') and a!="quit"):
raise ValueError("Value should be between 5 and 9")
a=str(input("enter the number:"))
s="quit"
b=input("enter the number2:")
sum=a+b
if a==s:
print(a+b)
elif sum
In this video lecture, we learnt about the raising custom errors using raise keyword. Sometimes, we want to impose hard and fast regulations so, we can use customer errors if something violates those regulations so, that it does not create any problem later in the program execution and that error can be handled at that point of time only. In the previous videos, we learnt about how to handle errors using exception handling with try, except and finally blocks. We can also make our custom error classes using any base case error with our defined set of rules to raise that error whenever it violates those rules.
pucha kisine?
LOL 🤣@@Aditya-jo1of
😂😂@@Aditya-jo1of
hm python video ni dkhinge tu hi pdha d commnts m......kuch b bkchdi😒😒😒🖕
@@VarshaSorout-vj9is Are nhi bro, vo tho bs apne yaad rkhne ke liye comments Kiya tha
a = input("Enter any value between 5 and 9: ")
try:
if(a=="quit"):
print("As You've chose to quit the program it is ended")
elif(int(a)9):
raise ValueError("Value should be between 5 and 9 ")
else:
print("Value Accepted")
except ValueError:
print("No Characters or Special Symbols are allowed")
a = input("Enter the value between 5 and 9: ")
while True:
try:
if (a == "quit"):
print("ohk")
break
elif 5
n = input("Enter the number for multiplication table : ")
if n == "quit":
print("Progarm End.")
exit()
try:
if int(n)6:
raise ValueError
else:
print(f"The Multiplication table of {n} is ----")
for i in range(10):
print(f"{n} X {i+1} = {int(n)*(i+1)}.")
except ValueError:
print("Enter a valid number!!!")
a = input("Enter a number between 5 and 9 - ")
def hi():
try:
if int(a)9:
return 1
except:
if a.lower() == 'quit':
print("Okay")
exit()
x=hi()
if x==1:
raise ValueError("Galat hai kuch")
else:
print("Fine")
SIMPLE AND EASY CODE
a = input("enter a value :")
b = 'quit'
if a == b:
print(b)
elif (a>5 or a
a = input("enter value between 5 and 9: ")
if a=="quit":
print("a")
elif(int(a)9 ):
raise ValueError("value should be between 5 to 9")
a = input('?')
if(a == 'quit'):
exit()
#return 0
if(int(a)
Add little more -------------------->
a = input("Enter a number between 5 and 8: ")
num = 0
if a == 'quit':
print("Good by!!")
exit(1)
try:
num = int(a)
except ValueError:
raise ValueError("Given value must be a number")
if 5 < int(num) > 9:
raise ValueError("Value must be between 5 and 8")
print("Success")
i succed your code
a = input("Enter a number between 5 and 8: ")
if a == 'quit':
print("Good by!!")
exit(1)
try:
a = int(a)
except ValueError:
raise ValueError("Given value must be a number")
if int(a)8:
raise ValueError("Value must be between 5 and 8")
print("Success")
a = input("Enter an integer(between 5 and 9) : ")
if a == "quit":
print("Works")
elif 5 < int(a) > 9:
raise ValueError("Please enter correct value")
num = input('enter num:')
if num == 'quit':
print('okay!')
elif int(num) 5:
raise ValueError('enter the num between 1 to 5')
quiz is done sir
# quit - Write a program to print quit only
a = input("Enter a word quit will be executed: ")
if (a == "quit"):
print("Quit is print")
else:
raise ValueError("Quizt is not ")
class five_div(Exception):
pass
try:
a = int(input("Enter a: "))
b = int(input("Enter b: "))
if b == 0:
raise ZeroDivisionError("Can't divide by Zero!")
elif b == 5:
raise five_div("Can't divide by five!")
else:
print(a/b)
except (ZeroDivisionError,five_div) as e: #handling multiple exceptions in one single except block
print(e)
except: #except of exception class
print("Error occured check your input!")
else:
print("All good!")
finally:
print("Program executed!")
Thanks !!
a = input("enter your number between 5 and 9:")
if a== "quit":
print("you are quit")
elif(int(a)9):
raise ValueError("value Between 9 or 5")
p=(input('enter your input-'))
if p=='quit':
pass
else:
if(int(p)9):
raise ValueError('value should be between 5 and 9')
else:
print('no error')
a= input("enter a number (should be from 5 to 9)
or to Exit type 'quit'
")
if(a=='quit'):
print("exited
")
elif(a!='quit' and a.isalpha() ):
raise ValueError("enter integer only
")
elif(int(a)9 ):
raise ValueError("value should be from 5 to 9
")
else:
print(f"the square of the number is: {int(a)**2}
")
print("thank you")
a=input("enter any number between 5 to 9:-")
if(a=="quit"):
print("ohk")
elif(int(a)9):
raise ValueError("invalid input")
else:
print("valid input")
a = input("Enter the number: ")
if a == "QUIET":
print("QUIET")
else:
a = int(a)
if a < 5 or a > 9:
raise ValueError("Value should be between 5 and 9")
num = input("Enter any value between 5 and 9: ")
if num == "quit":
print("Program quited")
else:
if num.isdigit():
if (int(num) >= 5 and int(num)
9:11
a = input( " Enter any value between 5 and 9: ")
if a == "quit":
print("quitting program")
exit()
elif a < "5" or a > "9":
raise ValueError( "Value should be between 5 and 9")
@GamersDen2 It's just muscle memory for me. My brain automatically added exit function.
And
suppose you have more code after the elif statement you want to execute if 'elif' is true then you need to add 'exit()' in 'if' statement.
finally aaj bhai ki hoodie change ho hi gayi😂😂
a=input("enter the value:")
class CustomError(Exception):
print("this is custom error ")
if(a=="quit"):
print("the value is \"quit\"")
else:
raise ValueError("the text is wrong")
with Or we can put number of between we should change if condition to if(5
def checkval():
while True:
a=input("enter value")
if(a=='quit'):
print("you quit")
break
try:
a=float(a)
if(a>9 or a