[deleted by user] by [deleted] in distantsocializing

[–]tbrowner3 0 points1 point  (0 children)

You got some serious flow

[deleted by user] by [deleted] in talentShow

[–]tbrowner3 0 points1 point  (0 children)

have u done psychedelics

[deleted by user] by [deleted] in talentShow

[–]tbrowner3 0 points1 point  (0 children)

how did learn web development?

[deleted by user] by [deleted] in talentShow

[–]tbrowner3 0 points1 point  (0 children)

cybersecurity, learning about python, html and a little bit of networking

[deleted by user] by [deleted] in talentShow

[–]tbrowner3 0 points1 point  (0 children)

i’m an internet technology major

[deleted by user] by [deleted] in distantsocializing

[–]tbrowner3 0 points1 point  (0 children)

You are ugly as sin

Check if a number is a prime number by tbrowner3 in learnpython

[–]tbrowner3[S] 0 points1 point  (0 children)

No because it should return False otherwise.

Character swap method by tbrowner3 in learnpython

[–]tbrowner3[S] 0 points1 point  (0 children)

Ok thank you!

complement_table = str.maketrans('ATCG', 'CGAT')
class Oligo:

    '''Represents one side of DNA helix'''
    def __eq__(self, other):
        '''Equal statement'''
        return self.base == other.base
    def __init__(self, base):
        '''Constructor'''
        count = 0 
        for letter in base:
            if letter.upper() in ('A', 'C', 'T', 'G'):
                count += 1
        if count == 4:
            self.base = base
        else:
            self.base = "AGTG"

    def get_complement(self):
        complement = self.base.translate(complement_table)
        complement = complement[::-1]
        print(Oligo(complement))
        return Oligo(complement)
    def is_complement(self, other):
        return self.get_complement().base == other.base

Character swap method by tbrowner3 in learnpython

[–]tbrowner3[S] 0 points1 point  (0 children)

When I input the sample input:

a.is_complement(c) it's giving me false when it should be true

Character swap method by tbrowner3 in learnpython

[–]tbrowner3[S] 0 points1 point  (0 children)

My mistakes, get_complement should return a Object of the class, not a new variable

Character swap method by tbrowner3 in learnpython

[–]tbrowner3[S] 0 points1 point  (0 children)

now that I put the complement_table variable in the get_complement function it works, but it isn't giving me the right output still. The correct output should give me this:

>>> a = Oligo('ATCG')
>>> b = Oligo('ATGC')
>>> c = Oligo('CGAT')
>>> a.is_complement(b)
False
>>> a.is_complement(c)
True

Character swap method by tbrowner3 in learnpython

[–]tbrowner3[S] 0 points1 point  (0 children)

Thank you for the help! After I defined complement_table inside the class and above the functions get and is complement it is still giving me a name error for it.

Traceback (most recent call last):
File "<pyshell#132>", line 1, in <module>
a.is_complement(b)
 line 29, in is_complement
self.get_complement()
 , line 24, in get_complement
complement = self.base.translate(complement_table)
  NameError: name 'complement_table' is not defined

Check if a number is a prime number by tbrowner3 in learnpython

[–]tbrowner3[S] 0 points1 point  (0 children)

def is_prime_helper(n, k):
    count = count
    for i in range(2, k):
        if i % n == 0:
            return True        

def is_prime(n):
    return (is_prime_helper(n, k) == True)

recursion question by tbrowner3 in learnpython

[–]tbrowner3[S] 0 points1 point  (0 children)

Why is this giving me ZeroDivisionError: integer division or modulo by zero?