Programming

Programming questions? Ask a programmer for answers ASAP

Ask a Computer Expert,
Get an Answer ASAP!

This answer was rated:

OKPR99211 I am learning Python and trying to better

OKPR99211 I am learning Python...

OKPR99211 I am learning Python and trying to better understand classes. In this simple example, why does the last statement, print D, not return, C = 3, and how would I access the variable C in other parts of my program? I am trying to understand how to create and modify variables inside a classes methods and then access those variables in other parts of my program. Thanks for helping me understand this issue. class Obj: A = 1 def __init__(self): B = 2 def tran(self): C = 3 this = Obj() D = this.tran() print D

Show More
Show Less
Ask Your Own Programming Question
Answered in 8 hours by:
9/10/2017
George Sibiya
George Sibiya, Computer Hardware Engineer
Category: Programming
Satisfied Customers: 364
Experience: PhD in Computer Science
Verified

Hi,

Welcome to JustAnswer and thank you for utilising our services

Please try return D instead of print D because that is what print does

Regards,

G

Ask Your Own Programming Question
Customer reply replied 10 months ago
What if i wanted to access multiple variables, can i return multiple

You'd need a function which returns the variable for each variable

George Sibiya
George Sibiya, Computer Hardware Engineer
Category: Programming
Satisfied Customers: 364
Experience: PhD in Computer Science
Verified
George Sibiya and 87 other Programming Specialists are ready to help you
Ask your own question now
Was this answer helpful?

How JustAnswer works

step-image
Describe your issueThe assistant will guide you
step-image
Chat 1:1 with a programmerLicensed Experts are available 24/7
step-image
100% satisfaction guaranteeGet all the answers you need
Ask George Sibiya Your Own Question
George Sibiya
George Sibiya
George Sibiya, Computer Hardware Engineer
Category: Programming
Satisfied Customers: 364
364 Satisfied Customers
Experience: PhD in Computer Science

George Sibiya is online now

A new question is answered every 9 seconds

How JustAnswer works:

  • Ask an ExpertExperts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional AnswerVia email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction GuaranteeRate the answer you receive.

JustAnswer in the News:

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

What Customers are Saying:

My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed.

One Happy CustomerNew York

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help.

Mary C.Freshfield, Liverpool, UK

This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!!

AlexLos Angeles, CA

Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult.

GPHesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.

JustinKernersville, NC

Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around.

EstherWoodstock, NY

Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know.

RobinElkton, Maryland

< Previous | Next >

Meet the Experts:

ATLPROG

ATLPROG

Computer Software Engineer

7,677 satisfied customers

MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML

LogicPro

LogicPro

Computer Software Engineer

7,175 satisfied customers

Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.

unvadim

unvadim

Computer Software Engineer

1,168 satisfied customers

Good knowledge of OOP principles. 3+ years of programming experience with Java and C++. Sun Certified Java Programmer 5.0.

lifesaver

lifesaver

Computer Software Engineer

950 satisfied customers

Several years of intensive programming and application development experience in various platforms.

ehabtutor

ehabtutor

Computer Software Engineer

936 satisfied customers

Bachelor of computer science, 5+ years experience in software development, software company owner

TheDoctor

TheDoctor

Software Engineer

893 satisfied customers

M.S. in Internet Information Systems

The-PC-Guy

The-PC-Guy

Software Engineer

848 satisfied customers

Extensive Knowledge in PHP, MYSQL, CSS & Javascript

< Previous | Next >

Related Programming Questions
How does this website work? Python - I am trying to figure
Python - I am trying to figure out how to remove a record in my json file based on a certain condition … read more
AMIT
AMIT
Bachelor's Degree
92 satisfied customers
Thank you! I had some questions with a python program, I'm
Thank you! I had some questions with a python program … read more
LogicPro
LogicPro
Computer Software Engineer
Bachelor of Technology
7,175 satisfied customers
Question 1 Youve been going to work on a database project
Question 1 You've been going to work on a database project at work for sometime now. Your boss encourages you to program the database in Python. You disagree, arguing that Python is not a database lan… read more
Arty
Arty
Senior Administrator
Bachelor\u0027s Degree
469 satisfied customers
Trying to laern Python 2.7.3 withTony Gaddis book Starting
Trying to laern Python 2.7.3 withTony Gaddis book Starting out with Python. I have problems with defining variables. Even after adding ..bar after the mainbar name my code gives errors like NameError:… read more
dmoola
dmoola
Programmer
Bachelor\u0027s Degree
14 satisfied customers
# XXXXX circle example import pygame # XXXXX pygame module class
# XXXXX circle example import pygame # XXXXX pygame module class Circle: #class definition statement "A 2D circle." #documentation string def __init__(self, x, y, radius=1): # XXXXX method self.x = x … read more
Proggy
Proggy
Programmer
90 satisfied customers
i want to write a lexicon class python program which includes
i want to write a lexicon class python program which includes a contains method which test to see if word exist in the file and is considered legal or illegal according to English syntax or rules so t… read more
Proggy
Proggy
Programmer
90 satisfied customers
_______ 1. The operator that is used to append or concatenate
_______ 1. The operator that is used to append or concatenate objects of String type is the ___________. A) >> B) + C) ! D) % _______ 2. The ____________ class comes from the swing library. A) O… read more
unvadim
unvadim
Computer Software Engineer
Diplom
1,168 satisfied customers
i have written a bit of code in python and it does not work
i have written a bit of code in python and it does not work and i cannot understand y it does not work can some plz help… read more
ATLPROG
ATLPROG
Computer Software Engineer
Master's Degree
7,677 satisfied customers
QUESTIONS TO BE ANSWERED ONLY BY Expert LogicPro Hi LogicPro The
QUESTIONS TO BE ANSWERED ONLY BY Expert LogicPro Hi LogicPro The correct answer for questions 4 in previous was A. final. There is a method modifier called friendly. Here are the next set of questions… read more
LogicPro
LogicPro
Computer Software Engineer
Bachelor of Technology
7,175 satisfied customers
Using the Point and Line classes described in Section 7.2, draw
Using the Point and Line classes described in Section 7.2, draw an isosceles triangle with the following configuration: (100, 30) (50, 100) (150, 100)… read more
LogicPro
LogicPro
Computer Software Engineer
Bachelor of Technology
7,175 satisfied customers
Create a method monthlyactivitySummary that outputs the number
Create a method monthlyactivitySummary that outputs the number of deposit and withdrawals for an account in the most recent month. Add one method for the Account class that you think as useful. The fo… read more
Arty
Arty
Senior Administrator
Bachelor\u0027s Degree
469 satisfied customers
First, define a class. The example below is just an example
First, define a class. The example below is just an example that defines a class named Account, you will need to enhance it to make it more realistic. class Account: def __init__(self, initial): self.… read more
LogicPro
LogicPro
Computer Software Engineer
Bachelor of Technology
7,175 satisfied customers
Create a method monthlyactivitySummary that outputs the number
Create a method monthlyactivitySummary that outputs the number of deposit and withdrawals for an account in the most recent month. Add one method for the Account class that you think as useful. The fo… read more
Arty
Arty
Senior Administrator
Bachelor\u0027s Degree
469 satisfied customers
Import the sample code below into the Python IDLE and enhance
Import the sample code below into the Python IDLE and enhance it, run it and debug it. Add features to make this a more realistic database tool by providing for easy data entry and retrieval. Export y… read more
DRouleau
DRouleau
College Diploma
105 satisfied customers
Do you still have the answer for the following It was answered
Do you still have the answer for the following: It was answered by you about 70 days ago? I'm using Active Python 2.6 and it is due tomorrow (Dec 7th). After seeing it posted and answered before I hop… read more
Cherryl Lewis
Cherryl Lewis
Bachelor's Degree
180 satisfied customers
I need help with my computer class and it deals with the program
I need help with my computer class and it deals with the program called python. Can any one help?… read more
Cherryl Lewis
Cherryl Lewis
Bachelor's Degree
180 satisfied customers
Youve been going to work on a database project at work for
You've been going to work on a database project at work for sometime now. Your boss encourages you to program the database in Python. You disagree, arguing that Python is not a database language but y… read more
Mike
Mike
Programmer
High School or GED
16 satisfied customers
I have to write a program in python that will allocate students
I have to write a program in python that will allocate students to tutorial sessions according to student preferences. Tutorials can only have a certain number of students. If the session is full I ha… read more
Mike B
Mike B
Computer Engineering Technologist
279 satisfied customers
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Show MoreShow Less

Ask Your Question

x