#๐Ÿ”’ want to get value of variables outside the functions to inside the function without the use of cla

49 messages ยท Page 1 of 1 (latest)

main valleyBOT
#

@bronze wasp

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

bronze wasp
ruby mulch
#

see python inhertance

bronze wasp
#

wdym

ruby mulch
#

thats the techinal term in software engineering, "inhertance"

bronze wasp
#

is that not to do with classes though

ruby mulch
#

works for everything tbh

#

functions raw variables

#

you declar A = y at the top of your code everything below inherts that

#

you return A from a function it goes backup to A

#

there is also the "global" varibles

bronze wasp
#

i tried global variables but i couldnt get it to work

#

i put global limit and global cardavlue at the start of the function

ruby mulch
#
a = 5
def cards(a):
  ### do a thing
  return a
print(a) # a will be whatever it is in "do a thing"```
bronze wasp
#

oh ok

#

thank you vert much for the help

ruby mulch
#

inhertance, constructors, instansation and polymorphism are all generic sofware engineering terms/concpets, once you master them you can find anythin in any lang you wanna do

#

๐Ÿ˜‰

bronze wasp
ruby mulch
bronze wasp
#

ok thanks i will read through it

ruby mulch
#

are you more a visual audio learner?

#

Object Oriented Programming is an important concept in software development. In this complete tutorial, you will learn all about OOP and how to implement it using Python.

๐Ÿ’ป Code: https://github.com/jimdevops19/PythonOOP

๐Ÿ”— Tutorial referenced for a deeper explanation about repr: https://www.youtube.com/watch?v=FIaPZXaePhw

โœ๏ธ Course develo...

โ–ถ Play video
bronze wasp
#

i will have a look at both because im really terrible at classes and stiff right now

#

thanks for the help

lean sky
#

It'll click.

arctic dune
#

inheritance has to do with modelling relationships between types of objects

#

a cow is an animal, for example

lean sky
#
class Animal:
    pass

class Cat(Animal):
    pass

class Cow(Animal):
    pass```
#

!e ```py
class Alpha:
def a(self):
print('alpha')

class Beta(Alpha):
def b(self):
print('beta')

alpha = Alpha()
beta = Beta()
beta.a()
beta.b()
alpha.a()
alpha.b()```

main valleyBOT
lean sky
#

Instances of Beta are everything that instances of Alpha are except where otherwise defined in Beta.

#

A cow is everything an animal is, plus the differences that make it a cow.

#

Inheritance is probably not especially relevant to your project.

harsh moat
ruby mulch
harsh moat
#

ah, i might have messed up in the "do something" bit

#

neat

ruby mulch
#

is the error you probably ran into

harsh moat
#

yeah, actually. i can feel my brain expanding!

ruby mulch
#

welcome to programming ๐Ÿ˜‰

harsh moat
#

i mixed the two ways of doing the thing up and half-failed both!

ruby mulch
#

i mean i broke out juypiter to test it

lean sky
main valleyBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.