input code:

output:

code:
'''make a class Area'''
class Area:
'''constructor'''
def __init__(self):
self.x=0
'''set x method'''
def setX(self,n):
if n<-0:
raise ValueError
else:
self.x=n
'''try catch block'''
try:
'''make object'''
a=Area()
'''take user input'''
inputValue=int(input("Enter a Value that is grater than 0:"))
'''set x'''
a.setX(inputValue)
'''except for handle a exceptions'''
except ValueError:
'''print value'''
print("Invalid Input Value Entered")
(python) [30] Implement exception handling with ValueError here in the following code: There are three blanks...
Below is Python code for logic gates. It is written for a specific Circuit. Do the following: 1) Fill in the appropriate If , Else statement for the OrGate ( Look at the AndGate for a hint ) 2) Create two new objects, the NandGate and the NorGate classes. 3) Look at the AndGate class. What does this class inherit and use from the BinaryGate class? class LogicGate: def __init__(self,n): self.name = n self.output = None def getName(self): return self.name...
This is the source code: Please incorporate the Exception
Handling
import javax.swing.JOptionPane;
import java.awt.*;
public class GuessingGame {
public static void main(String[] args) {
int computerNumber = (int) (Math.random() * 10 + 1);
System.out.println("The correct guess would be " +
computerNumber);
int userAnswer = 0;
int count = 0;
while (computerNumber != userAnswer) {
count++;
String response = JOptionPane.showInputDialog(null,
"Enter a guess between 1 and 10");
userAnswer = Integer.parseInt(response);
String result = null;
if (userAnswer == computerNumber) {
result =...
Please convert the following python program to LINE BY LINE python pseudocode. Please convert LINE BY LINE (typed) class vector: def __init__(self,x,y): self.x = x # Assigning x to vector's x self.y = y # Assigning y to vector's y def __str__(self): return '('+str(self.x)+","+str(self.y)+')' # This returns the value of vector in bracket format def __add__(self,other): x = self.x+other.x # values of x of vector1 and vector2 are added forming new x value y = self.y+other.y # same is done...
I'm trying to run the code in Python below and keep getting invalid syntax. What's wrong? Thanks for any help! def even(n): if n%2==0 #Enter a Number def main(): n=int(input("Enter a number: ")) #If even print "Number is even" if(even(n)): print("The number is even") #If odd print "Number is odd" else: print("The number is odd") main() #Call the main function
Please write a code in python! Define and test a function named posterize. This function expects an image and a tuple of RGB values as arguments. The function modifies the image like the blackAndWhite function, but it uses the given RGB values instead of black. images.py import tkinter import os, os.path tk = tkinter _root = None class ImageView(tk.Canvas): def __init__(self, image, title = "New Image", autoflush=False): master = tk.Toplevel(_root) master.protocol("WM_DELETE_WINDOW", self.close) tk.Canvas.__init__(self, master, width = image.getWidth(), height = image.getHeight())...
PYTHON: Conan is writing a module to contain different implementations of trees. After his first tree, the BinaryTreeclass, he wrote test code and is having problems understanding the error. Locate his problem and explain how you would fix it. class Node(object): def __init__(self, data=None): self.data = data def __str__(self): return "NODE: " + str(self.data) class Tree(object): def __init__(self): self.root_node = None self.size = 0 def __len__(self): return self.size def add(self, data): raise NotImplementedError("Add method not implemented.") def inorder_traversal(self): raise NotImplementedError("inorder_traversal...
Create a two new gate classes, one called NorGate the other called NandGate. NandGates work like AndGates that have a Not attached to the output. NorGates work lake OrGates that have a Not attached to the output.Create a series of gates that prove the following equality NOT (( A and B) or (C and D)) is that same as NOT( A and B ) and NOT (C and D). Make sure to use some of your new gates in the...
The goal of this code is to draw a smiley face and be able to change emotion, mouth and eyes. Use the demo code below to fill in the blanks ( ), as well as add any other methods or data that is needed. All blanks should be completed with a single line of code (or partial line). You should not modify any other code that exists. Only remove the blanks and add other missing methods. Use a radius of...
Page 3 of 7 (Python) For each substring in the input string t that matches the regular expression r, the method call re. aub (r, o, t) substitutes the matching substring with the string a. Wwhat is the output? import re print (re.aub (r"l+\d+ " , "$, "be+345jk3726-45+9xyz")) a. "be$jk3726-455xyz" c. "bejkxyz" 9. b. "be$jks-$$xyz" d. $$$" A object a- A (2) 10. (Python) What is the output? # Source code file: A.py class A init (self, the x): self.x-...