• Register
2 votes
76 views

Problem:

I am new in python programming so I am always confused about what is going wrong with my code. Recently I write a code:
class showInformation(object):
 
    def __int__(self, name, age):
        self.name = name
        self.age = age

def showName(self):
    print("Your Name: "+self.name)
def showAge(self):
    print("Your Age: "+self.age)


Info = showInformation("XXX")

Info.showName()

Which gives me following error:

Traceback (most recent call last):
  File "main.py", line 13, in <module>
    Info = showInformation("XXX")
TypeError: showInformation() takes no arguments
typeerror: object() takes no parameters

Whats wrong In my code can anyone explain?

10 7 2
6,060 points

Please log in or register to answer this question.

1 Answer

1 vote
 
Best answer

Answer:

In your program you should write:

def __int__(self, name, age):

As:

def __init__(self, name, age):

And your code should be like:

class showInformation(object):
 
    def __init__(self, name, age):
        self.name = name
        self.age = age

def showName(self):
    print("Your Name: "+self.name)
def showAge(self):
    print("Your Age: "+self.age)


Info = showInformation("bot", "20")

Info.showName()

Let me know if it is working for you or not.

11 6 4
34,950 points

Related questions

1 vote
1 answer 53 views
53 views
Problem: For a python programm which I wrote I get some error message as: Traceback (most recent call last): File "info.py", line 13, in <module> Info = showInformation("XXX") TypeError: showInformation() takes no arguments typeerror: object() takes no parameters The ... XXX") Info.showName() Is there any problem in my program. What is this error caused by. Can anyone help? Thanks in advance.
asked Apr 29, 2020 samhaz 5k points
0 votes
1 answer 18 views
18 views
I am creating a cookie clicker game, where there is a surface that displays how many cookies I have. Here is my code for drawing text. def draw_text(self, text, font_name, size, color, x, y, align="nw"): font = pg.font.Font(font_name, size) text_surface = ... does self.draw_text('Cookies: {}'.format(len(self.cookie_count)) give me an error? How come the length of self.cookie_count is not printed?
asked Oct 25, 2020 psandprop 2.4k points
1 vote
1 answer 71 views
71 views
Problem: Hello everyone, I am trying to create a webscraper which will take links from CSV file and scrape data. but whenever I run this code it says the object of nonetype has no len(). Below is my code: import requests from bs4 import BeautifulSoup import time ... text return data def main(): read_file() datas = parse_data() writedata(datas, "UP_DATA.csv") main() What&rsquo;s going wrong here?
asked Mar 7, 2020 Gavin 15.3k points
0 votes
1 answer 9 views
9 views
Problem: TypeError: &lsquo;float&rsquo; object cannot be interpreted as an integer Floating-point numbers are values that can contain a decimal point. Integers are whole numbers. It is common in programming for these two data types to be distinct.How to solve this error
asked Jan 6 Mashhoodch 6.3k points
0 votes
1 answer 20 views
20 views
Problem: Hi there! I am a noob and I have got an assignment in which I have to take two numbers as input from users and print the even numbers that lie between two numbers. I wrote the following program: starting = input("Enter the starting number: ") ending = ... : TypeError: 'str' object cannot be interpreted as an integer I have no idea what is wrong with my program. Can anybody here help me?
asked Dec 21, 2020 Code Learner 5.5k points
1 vote
1 answer 81 views
81 views
Problem: Here is my sample code below from turtle import * speed(0) hideturtle() c = 450 def grid(x,y,a): seth(0) pu() goto(x,y) pd() for i in range(4): forward(a) rt(90) for i in range(c/10): seth(0) forward(10) rt(90) forward(c) backward(c ... \Desktop\gridv2.py", line 15, in grid for i in range(c/10): TypeError: 'float' object cannot be interpreted as an integer What&rsquo;s wrong with my code?
asked Mar 7, 2020 Gavin 15.3k points
1 vote
1 answer 24 views
24 views
Problem: Can anyone guide me with the right solution as I am new and learning programming? Write the code to call the function named send_signal. there are no parameters for this function?
asked Feb 18, 2020 maddi86 5.4k points