SlideShare ist ein Scribd-Unternehmen logo
For any help regarding Python Homework Help
Visit :- https://www.pythonhomeworkhelp.com/ ,
Email :- support@pythonhomeworkhelp.com or
Call/ Text/ WhatsApp: +1(315)557-6473
Problems and Solutions:
Problem 1 – Quick exploration of member functions
We've taught you that objects encapsulate data, and they provide member functions that operate
based on that data. Some member functions change that data – in that case, they're modifiers
and the object is mutable – while others simply return new data.
The syntax for accessing member functions of objects is:
where variable points to an object in the heap.
Since the primitive types int, float and bool are NOT objects, they don't support any member
functions. So you CAN'T do 5.something() or True.something().
However, strings are objects, so they support member functions. Same with tuples, and same
with lists. What member functions do each support? Python provides a "dir" function that takes a
variable and lists the member functions that the object supports.
For any help regarding Python Homework Help
Visit :- https://www.pythonhomeworkhelp.com/ ,
Email :- support@pythonhomeworkhelp.com or
Call/ Text/ WhatsApp: +1(315)557-6473
You should get out a bunch of what looks like jumbled nonsense. But those things are actually
member functions of each object. You'll generally see two types of member functions:
__functionname__ functions are generally not meant to be explicitly called. Instead, they're
used by Python to do other things.
Å "A" comes before "B" alphabetically, so this is True
For any help regarding Python Homework Help
Visit :- https://www.pythonhomeworkhelp.com/ ,
Email :- support@pythonhomeworkhelp.com or
Call/ Text/ WhatsApp: +1(315)557-6473
We see the same result. It turns out that whenever you write object1 < object2, Python looks for
a __lt__ member function in a and calls it with b as the argument. (In actuality, there is a little
more to the story, but we won't worry about that now.)
The __functionname__ style exists because it's meant to explicitly make it clear that this
function is not meant to be called normally. It's a system function, so in general, we should never
be calling functions with names like __functionname__.
The rest of the functions are all functions that you can use! For help with any, type:
Take a quick look at some of the functions for strings, lists and tuples... we'll be needing them.
For any help regarding Python Homework Help
Visit :- https://www.pythonhomeworkhelp.com/ ,
Email :- support@pythonhomeworkhelp.com or
Call/ Text/ WhatsApp: +1(315)557-6473
Let's say there are two methods to find the "distance" of two chromosomes -- that is, how much
the two have varied through mutations. One method is to go letter by letter and count the
number of discrepancies. Another method is to sum the discrepancies of a's (e.g. chromosome x
has 5 a's, chromosome y has 7 a's), c's, g’s, and t’s.
Are the two methods the same? We don't know, let's find out.
Write a function that uses method 1. It will take two chromosomes, and go letter by letter in
each, comparing them. It then returns the total number of discrepancies it finds.
Write another function that uses method 2. It will take two chromosomes, and return the sum of
'a' discrepancies, ‘cones, and so on.
Then call each function on each of the combinations (A,B), (A,C), (A,D), (B,C), (B, D), and (C, D)
and see which methods tell you which pair of chromosomes is "furthest" (i.e. most varied) and
which pair is "closest" (i.e. least varied).
Remember to use dir()!
Important note: From this point on, we are going to stray from interactive programs that use
raw_input and go to solving complex problems instead. You should not use a raw_input function
anywhere in this program.
For any help regarding Python Homework Help
Visit :- https://www.pythonhomeworkhelp.com/ ,
Email :- support@pythonhomeworkhelp.com or
Call/ Text/ WhatsApp: +1(315)557-6473
A = "gtggcaacgtgc"
B = "gtagcagcgcgc"
C = "gcggcacagggt"
D = "gtgacaacgtgc"
def method1(c1, c2):
discreps = 0
for i in range(len(c1)):
if c1[i] != c2[i]:
discreps = discreps + 1
return discreps
def method2(c1, c2):
discreps_a = abs(c1.count('a') - c2.count('a'))
discreps_c = abs(c1.count('c') - c2.count('c'))
discreps_g = abs(c1.count('g') - c2.count('g'))
discreps_t = abs(c1.count('t') - c2.count('t'))
return discreps_a + discreps_c + discreps_g + discreps_t
For any help regarding Python Homework Help
Visit :- https://www.pythonhomeworkhelp.com/ ,
Email :- support@pythonhomeworkhelp.com or
Call/ Text/ WhatsApp: +1(315)557-6473
def compare(c1, c2, name1, name2):
print name1, "and", name2, ":"
print "Method 1 says there are", method1(c1, c2),
"differences."
print "Method 2 says there are", method2(c1, c2),
"differences."
print
compare(A, B, "A", "B")
compare(A, C, "A", "C")
compare(A, D, "A", "D")
compare(B, C, "B", "C")
compare(B, D, "B", "D")
compare(C, D, "C", "D")
For any help regarding Python Homework Help
Visit :- https://www.pythonhomeworkhelp.com/ ,
Email :- support@pythonhomeworkhelp.com or
Call/ Text/ WhatsApp: +1(315)557-6473

Weitere ähnliche Inhalte

Ähnlich wie Python Homework Help

ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
priestmanmable
 
Programming with Python - Week 3
Programming with Python - Week 3Programming with Python - Week 3
Programming with Python - Week 3
Ahmet Bulut
 
Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...
Simplilearn
 
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptxKripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
sg4795
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2
sadhana312471
 
Elegant Solutions For Everyday Python Problems - PyCon Canada 2017
Elegant Solutions For Everyday Python Problems - PyCon Canada 2017Elegant Solutions For Everyday Python Problems - PyCon Canada 2017
Elegant Solutions For Everyday Python Problems - PyCon Canada 2017
Nina Zakharenko
 
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
Mukul Kirti Verma
 
Phyton Learning extracts
Phyton Learning extracts Phyton Learning extracts
Phyton Learning extracts
Pavan Babu .G
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methods
PranavSB
 
C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]
Rome468
 
Python for dummies
Python for dummiesPython for dummies
Python for dummies
Roberto Stefanetti
 
python full notes data types string and tuple
python full notes data types string and tuplepython full notes data types string and tuple
python full notes data types string and tuple
SukhpreetSingh519414
 
Anton Kasyanov, Introduction to Python, Lecture2
Anton Kasyanov, Introduction to Python, Lecture2Anton Kasyanov, Introduction to Python, Lecture2
Anton Kasyanov, Introduction to Python, Lecture2Anton Kasyanov
 
python interview prep question , 52 questions
python interview prep question , 52 questionspython interview prep question , 52 questions
python interview prep question , 52 questions
gokul174578
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
Dozie Agbo
 
PYTHON PPT.pptx
PYTHON PPT.pptxPYTHON PPT.pptx
PYTHON PPT.pptx
AbhishekMourya36
 
Python and You Series
Python and You SeriesPython and You Series
Python and You Series
Karthik Prakash
 
Top Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdfTop Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdf
Datacademy.ai
 
Basic of python for data analysis
Basic of python for data analysisBasic of python for data analysis
Basic of python for data analysis
Pramod Toraskar
 

Ähnlich wie Python Homework Help (20)

ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
 
Programming with Python - Week 3
Programming with Python - Week 3Programming with Python - Week 3
Programming with Python - Week 3
 
Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...
 
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptxKripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
 
Dynamic Python
Dynamic PythonDynamic Python
Dynamic Python
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2
 
Elegant Solutions For Everyday Python Problems - PyCon Canada 2017
Elegant Solutions For Everyday Python Problems - PyCon Canada 2017Elegant Solutions For Everyday Python Problems - PyCon Canada 2017
Elegant Solutions For Everyday Python Problems - PyCon Canada 2017
 
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
 
Phyton Learning extracts
Phyton Learning extracts Phyton Learning extracts
Phyton Learning extracts
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methods
 
C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]
 
Python for dummies
Python for dummiesPython for dummies
Python for dummies
 
python full notes data types string and tuple
python full notes data types string and tuplepython full notes data types string and tuple
python full notes data types string and tuple
 
Anton Kasyanov, Introduction to Python, Lecture2
Anton Kasyanov, Introduction to Python, Lecture2Anton Kasyanov, Introduction to Python, Lecture2
Anton Kasyanov, Introduction to Python, Lecture2
 
python interview prep question , 52 questions
python interview prep question , 52 questionspython interview prep question , 52 questions
python interview prep question , 52 questions
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
PYTHON PPT.pptx
PYTHON PPT.pptxPYTHON PPT.pptx
PYTHON PPT.pptx
 
Python and You Series
Python and You SeriesPython and You Series
Python and You Series
 
Top Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdfTop Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdf
 
Basic of python for data analysis
Basic of python for data analysisBasic of python for data analysis
Basic of python for data analysis
 

Mehr von Python Homework Help

Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
Python Homework Help
 
Complete my Python Homework
Complete my Python HomeworkComplete my Python Homework
Complete my Python Homework
Python Homework Help
 
Introduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptxIntroduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptx
Python Homework Help
 
Basic Python Programming.pptx
Basic Python Programming.pptxBasic Python Programming.pptx
Basic Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
Python Homework Help
 
Python Programming Homework Help.pptx
Python Programming Homework Help.pptxPython Programming Homework Help.pptx
Python Programming Homework Help.pptx
Python Homework Help
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
Python Homework Help
 
Perfect Python Homework Help
Perfect Python Homework HelpPerfect Python Homework Help
Perfect Python Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
Python Homework Help
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
Python Homework Help
 

Mehr von Python Homework Help (20)

Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Complete my Python Homework
Complete my Python HomeworkComplete my Python Homework
Complete my Python Homework
 
Introduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptxIntroduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptx
 
Basic Python Programming.pptx
Basic Python Programming.pptxBasic Python Programming.pptx
Basic Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Programming Homework Help.pptx
Python Programming Homework Help.pptxPython Programming Homework Help.pptx
Python Programming Homework Help.pptx
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
 
Perfect Python Homework Help
Perfect Python Homework HelpPerfect Python Homework Help
Perfect Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 

Kürzlich hochgeladen

Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 

Kürzlich hochgeladen (20)

Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 

Python Homework Help

  • 1. For any help regarding Python Homework Help Visit :- https://www.pythonhomeworkhelp.com/ , Email :- support@pythonhomeworkhelp.com or Call/ Text/ WhatsApp: +1(315)557-6473
  • 2. Problems and Solutions: Problem 1 – Quick exploration of member functions We've taught you that objects encapsulate data, and they provide member functions that operate based on that data. Some member functions change that data – in that case, they're modifiers and the object is mutable – while others simply return new data. The syntax for accessing member functions of objects is: where variable points to an object in the heap. Since the primitive types int, float and bool are NOT objects, they don't support any member functions. So you CAN'T do 5.something() or True.something(). However, strings are objects, so they support member functions. Same with tuples, and same with lists. What member functions do each support? Python provides a "dir" function that takes a variable and lists the member functions that the object supports. For any help regarding Python Homework Help Visit :- https://www.pythonhomeworkhelp.com/ , Email :- support@pythonhomeworkhelp.com or Call/ Text/ WhatsApp: +1(315)557-6473
  • 3. You should get out a bunch of what looks like jumbled nonsense. But those things are actually member functions of each object. You'll generally see two types of member functions: __functionname__ functions are generally not meant to be explicitly called. Instead, they're used by Python to do other things. Å "A" comes before "B" alphabetically, so this is True For any help regarding Python Homework Help Visit :- https://www.pythonhomeworkhelp.com/ , Email :- support@pythonhomeworkhelp.com or Call/ Text/ WhatsApp: +1(315)557-6473
  • 4. We see the same result. It turns out that whenever you write object1 < object2, Python looks for a __lt__ member function in a and calls it with b as the argument. (In actuality, there is a little more to the story, but we won't worry about that now.) The __functionname__ style exists because it's meant to explicitly make it clear that this function is not meant to be called normally. It's a system function, so in general, we should never be calling functions with names like __functionname__. The rest of the functions are all functions that you can use! For help with any, type: Take a quick look at some of the functions for strings, lists and tuples... we'll be needing them. For any help regarding Python Homework Help Visit :- https://www.pythonhomeworkhelp.com/ , Email :- support@pythonhomeworkhelp.com or Call/ Text/ WhatsApp: +1(315)557-6473
  • 5. Let's say there are two methods to find the "distance" of two chromosomes -- that is, how much the two have varied through mutations. One method is to go letter by letter and count the number of discrepancies. Another method is to sum the discrepancies of a's (e.g. chromosome x has 5 a's, chromosome y has 7 a's), c's, g’s, and t’s. Are the two methods the same? We don't know, let's find out. Write a function that uses method 1. It will take two chromosomes, and go letter by letter in each, comparing them. It then returns the total number of discrepancies it finds. Write another function that uses method 2. It will take two chromosomes, and return the sum of 'a' discrepancies, ‘cones, and so on. Then call each function on each of the combinations (A,B), (A,C), (A,D), (B,C), (B, D), and (C, D) and see which methods tell you which pair of chromosomes is "furthest" (i.e. most varied) and which pair is "closest" (i.e. least varied). Remember to use dir()! Important note: From this point on, we are going to stray from interactive programs that use raw_input and go to solving complex problems instead. You should not use a raw_input function anywhere in this program. For any help regarding Python Homework Help Visit :- https://www.pythonhomeworkhelp.com/ , Email :- support@pythonhomeworkhelp.com or Call/ Text/ WhatsApp: +1(315)557-6473
  • 6. A = "gtggcaacgtgc" B = "gtagcagcgcgc" C = "gcggcacagggt" D = "gtgacaacgtgc" def method1(c1, c2): discreps = 0 for i in range(len(c1)): if c1[i] != c2[i]: discreps = discreps + 1 return discreps def method2(c1, c2): discreps_a = abs(c1.count('a') - c2.count('a')) discreps_c = abs(c1.count('c') - c2.count('c')) discreps_g = abs(c1.count('g') - c2.count('g')) discreps_t = abs(c1.count('t') - c2.count('t')) return discreps_a + discreps_c + discreps_g + discreps_t For any help regarding Python Homework Help Visit :- https://www.pythonhomeworkhelp.com/ , Email :- support@pythonhomeworkhelp.com or Call/ Text/ WhatsApp: +1(315)557-6473
  • 7. def compare(c1, c2, name1, name2): print name1, "and", name2, ":" print "Method 1 says there are", method1(c1, c2), "differences." print "Method 2 says there are", method2(c1, c2), "differences." print compare(A, B, "A", "B") compare(A, C, "A", "C") compare(A, D, "A", "D") compare(B, C, "B", "C") compare(B, D, "B", "D") compare(C, D, "C", "D") For any help regarding Python Homework Help Visit :- https://www.pythonhomeworkhelp.com/ , Email :- support@pythonhomeworkhelp.com or Call/ Text/ WhatsApp: +1(315)557-6473