SlideShare a Scribd company logo
+
Dr. Ramadan Babers
Faculty of Science - Helwan University
Spring – 2019
Python
LEC - 03
for
Biologists
https://www.linkedin.com/in/ramadan-babers-phd-78976345
+
Printing
and
Manipulating Text
(Continue)
2
Chapter: 2
3
Storing strings in variables
We can take a string and assign a name to it
using an equals sign – we call this a variable:
We can use the variable name instead of the
string itself – for example, we can use it in a print
statement
4
Storing strings in variables
variable names are arbitrary – that means that
we can pick whatever we like to be the name of
a variable.
variable names are case-sensitive,so
 my_dna,
 MY_DNA,
 My_DNA and
 My_Dna
are all separate variables.
5Tools for manipulating strings
1- Concatenation
We can concatenate (stick together) two strings
using the + symbol1 .This symbol will join
together the string on the left with the string on
the right:
6Tools for manipulating strings
1- Concatenation (cont.)
use variables that point to strings:
join multiple strings together in one go:
concatenation inside a print statement:
7Tools for manipulating strings
2- Finding the length of a string
useful built-in tool in Python is the len function (len is short for length).
No output appears
Why ??????
we need to store it in a variable
8Tools for manipulating strings
2- Finding the length of a string
Python treats strings and numbers differently.
len function: the result (or return value) is not a string, it's a number.
calculates the length of a DNA sequence
and then prints a message telling us the length:
my_dna = "ATGCGAGT"
dna_length = len(my_dna)
print("The length of the DNA sequence is " + dna_length)
9Tools for manipulating strings
2- Finding the length of a string
Python has a built-in solution – a function called str which
turns a numberinto a string so that we can print it.
10Tools for manipulating strings
3- Changing case
A method is like a function, but instead of being built in to the Python language,
it belongs to a particular type.
Method & Function
Ex. lower and upper are belong to the string type.
11Tools for manipulating strings
3- Changing case (Quiz)
Upper case: ATGC
Lower case: atgc
Write a python code that print the sequence of DNA “ATGC” in
lower and upper case. The result will as shown below.
12Tools for manipulating strings
4- Replacement
it takes two arguments (both strings) and returns a copy of the variable
where all occurrences of the first string are replaced by the second
string.
replace method
replace("v", "y")
replace("vls", "ymt")
the original variable
13Tools for manipulating strings
5- Extracting part of a string
If we want a short portion of a long string, this is known as taking a substring. To get
it, we follow the variable name with a pair of square brackets which enclose a start
and stop position, separated by a colon (:).
protein = "vlspadktnv"
print(protein[3:5])
print(protein[0:6])
print(protein[0:60])
14Tools for manipulating strings
6- Counting and finding substrings
A very common job in biology is to count the number
of times some pattern occurs in a DNA or protein
sequence.
counting the number of times a
substring occurs in a string.
method that does the job is
called count
15Tools for manipulating strings
6- Counting and finding substrings
Count
Example
16Tools for manipulating strings
6- Counting and finding substrings
find method takes a single string argument, just like count, and
returns a number which is the position at which that substring first
appears in the string
the index of the substring
17Tools for manipulating strings
6- Counting and finding substrings
Find
Example
What is this?

More Related Content

What's hot

Yara
YaraYara
Introduction to YARA rules
Introduction to YARA rulesIntroduction to YARA rules
Introduction to YARA rules
n|u - The Open Security Community
 
Binary search algorithm
Binary search algorithmBinary search algorithm
Binary search algorithm
maamir farooq
 
Text Analytics
Text AnalyticsText Analytics
Text AnalyticsAjay Ram
 
Convert grammar to cnf
Convert grammar to cnfConvert grammar to cnf
Convert grammar to cnf
Dr. ABHISHEK K PANDEY
 
Quick sort
Quick sortQuick sort
Quick sort
Fabia Nayeem
 
Anfis (1)
Anfis (1)Anfis (1)
Anfis (1)
TarekBarhoum
 
Dotnet programming concepts difference faqs- 3
Dotnet programming concepts difference faqs- 3Dotnet programming concepts difference faqs- 3
Dotnet programming concepts difference faqs- 3
Umar Ali
 
Binary Search
Binary SearchBinary Search
Binary Search
kunj desai
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary search
Nisha Soms
 
Binary search
Binary searchBinary search
Binary search
AparnaKumari31
 
Java String
Java StringJava String
Java String
Java2Blog
 
Bubble Sort Algorithm Presentation
Bubble Sort Algorithm Presentation Bubble Sort Algorithm Presentation
Bubble Sort Algorithm Presentation
AhmedAlbutty
 
Database structure Structures Link list and trees and Recurison complete
Database structure Structures Link list and trees and Recurison complete  Database structure Structures Link list and trees and Recurison complete
Database structure Structures Link list and trees and Recurison complete
Adnan abid
 
Data structure lecture 1
Data structure   lecture 1Data structure   lecture 1
Data structure lecture 1
Samsil Arefin
 
Expression trees
Expression treesExpression trees
Expression trees
Salman Vadsarya
 

What's hot (18)

Yara
YaraYara
Yara
 
Introduction to YARA rules
Introduction to YARA rulesIntroduction to YARA rules
Introduction to YARA rules
 
Binary search algorithm
Binary search algorithmBinary search algorithm
Binary search algorithm
 
Text Analytics
Text AnalyticsText Analytics
Text Analytics
 
Convert grammar to cnf
Convert grammar to cnfConvert grammar to cnf
Convert grammar to cnf
 
Quick sort
Quick sortQuick sort
Quick sort
 
String, string builder, string buffer
String, string builder, string bufferString, string builder, string buffer
String, string builder, string buffer
 
Anfis (1)
Anfis (1)Anfis (1)
Anfis (1)
 
Dotnet programming concepts difference faqs- 3
Dotnet programming concepts difference faqs- 3Dotnet programming concepts difference faqs- 3
Dotnet programming concepts difference faqs- 3
 
Binary Search
Binary SearchBinary Search
Binary Search
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary search
 
Binary search
Binary searchBinary search
Binary search
 
Java String
Java StringJava String
Java String
 
Dec 14 - R2
Dec 14 - R2Dec 14 - R2
Dec 14 - R2
 
Bubble Sort Algorithm Presentation
Bubble Sort Algorithm Presentation Bubble Sort Algorithm Presentation
Bubble Sort Algorithm Presentation
 
Database structure Structures Link list and trees and Recurison complete
Database structure Structures Link list and trees and Recurison complete  Database structure Structures Link list and trees and Recurison complete
Database structure Structures Link list and trees and Recurison complete
 
Data structure lecture 1
Data structure   lecture 1Data structure   lecture 1
Data structure lecture 1
 
Expression trees
Expression treesExpression trees
Expression trees
 

Similar to Python lec 1003_for_biologists

Php, mysqlpart2
Php, mysqlpart2Php, mysqlpart2
Php, mysqlpart2
Subhasis Nayak
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYRajeshkumar Reddy
 
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3Anton Kasyanov
 
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdfCOMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
rajkumar2792005
 
Python ppt_118.pptx
Python ppt_118.pptxPython ppt_118.pptx
Python ppt_118.pptx
MadhuriAnaparthy
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
Eduardo Bergavera
 
Chapter - 2.pptx
Chapter - 2.pptxChapter - 2.pptx
Chapter - 2.pptx
MikialeTesfamariam
 
String in python lecture (3)
String in python lecture (3)String in python lecture (3)
String in python lecture (3)
Ali ٍSattar
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
faithxdunce63732
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9Vince Vo
 
ppt notes python language operators and data
ppt notes python language operators and datappt notes python language operators and data
ppt notes python language operators and data
SukhpreetSingh519414
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
rohithprabhas1
 
Compiler Design File
Compiler Design FileCompiler Design File
Compiler Design File
Archita Misra
 
Python Strings Methods
Python Strings MethodsPython Strings Methods
Python Strings Methods
Mr Examples
 
5
55
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
nmahi96
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...ijceronline
 
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...
jaychoudhary37
 

Similar to Python lec 1003_for_biologists (20)

Php, mysqlpart2
Php, mysqlpart2Php, mysqlpart2
Php, mysqlpart2
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDY
 
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3
 
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdfCOMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
 
Python ppt_118.pptx
Python ppt_118.pptxPython ppt_118.pptx
Python ppt_118.pptx
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
 
Chapter - 2.pptx
Chapter - 2.pptxChapter - 2.pptx
Chapter - 2.pptx
 
String in python lecture (3)
String in python lecture (3)String in python lecture (3)
String in python lecture (3)
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
 
ppt notes python language operators and data
ppt notes python language operators and datappt notes python language operators and data
ppt notes python language operators and data
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
 
LectureNotes-04-DSA
LectureNotes-04-DSALectureNotes-04-DSA
LectureNotes-04-DSA
 
Compiler Design File
Compiler Design FileCompiler Design File
Compiler Design File
 
Python Strings Methods
Python Strings MethodsPython Strings Methods
Python Strings Methods
 
5
55
5
 
Python slide.1
Python slide.1Python slide.1
Python slide.1
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
 
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_06-Dec...
 

More from Ramadan Babers, PhD

Part10 finance investment limitations of ratio analysis
Part10 finance investment limitations of ratio analysisPart10 finance investment limitations of ratio analysis
Part10 finance investment limitations of ratio analysis
Ramadan Babers, PhD
 
Part09 finance investment ratio analysis investment ratio
Part09 finance investment ratio analysis investment ratioPart09 finance investment ratio analysis investment ratio
Part09 finance investment ratio analysis investment ratio
Ramadan Babers, PhD
 
Part08 finance investment ratio analysis solvency ratio
Part08 finance investment ratio analysis solvency ratioPart08 finance investment ratio analysis solvency ratio
Part08 finance investment ratio analysis solvency ratio
Ramadan Babers, PhD
 
Part07 finance investment ratio analysis profitability ratio
Part07 finance investment ratio analysis profitability ratioPart07 finance investment ratio analysis profitability ratio
Part07 finance investment ratio analysis profitability ratio
Ramadan Babers, PhD
 
Part06 finance investment ratio analysis efficiency ratio
Part06 finance investment ratio analysis efficiency ratioPart06 finance investment ratio analysis efficiency ratio
Part06 finance investment ratio analysis efficiency ratio
Ramadan Babers, PhD
 
Part05 finance investment_ratio_analysis_liquidity_ratio_presentation
Part05 finance investment_ratio_analysis_liquidity_ratio_presentationPart05 finance investment_ratio_analysis_liquidity_ratio_presentation
Part05 finance investment_ratio_analysis_liquidity_ratio_presentation
Ramadan Babers, PhD
 
Part04 finance investment_ratio_analysis_introduction_presentation
Part04 finance investment_ratio_analysis_introduction_presentationPart04 finance investment_ratio_analysis_introduction_presentation
Part04 finance investment_ratio_analysis_introduction_presentation
Ramadan Babers, PhD
 
Part03 finance investment_financial_statement_analysis_presentation
Part03 finance investment_financial_statement_analysis_presentationPart03 finance investment_financial_statement_analysis_presentation
Part03 finance investment_financial_statement_analysis_presentation
Ramadan Babers, PhD
 
Part02 finance investment_finance_and_financial_reporting_presentation
Part02 finance investment_finance_and_financial_reporting_presentationPart02 finance investment_finance_and_financial_reporting_presentation
Part02 finance investment_finance_and_financial_reporting_presentation
Ramadan Babers, PhD
 
Part01 finance investment_basics_presentation
Part01 finance investment_basics_presentationPart01 finance investment_basics_presentation
Part01 finance investment_basics_presentation
Ramadan Babers, PhD
 
Strategic Management part_03_03
Strategic Management part_03_03Strategic Management part_03_03
Strategic Management part_03_03
Ramadan Babers, PhD
 
Strategic Management part_02_03
Strategic Management part_02_03Strategic Management part_02_03
Strategic Management part_02_03
Ramadan Babers, PhD
 
Strategic Management part_01_03
Strategic Management part_01_03Strategic Management part_01_03
Strategic Management part_01_03
Ramadan Babers, PhD
 
Customer Experience (CX) updated version V9.0
Customer Experience (CX) updated version V9.0Customer Experience (CX) updated version V9.0
Customer Experience (CX) updated version V9.0
Ramadan Babers, PhD
 
Classification using decision tree in detail
Classification using decision tree in detailClassification using decision tree in detail
Classification using decision tree in detail
Ramadan Babers, PhD
 
Customer Experience (CX)
Customer Experience (CX)Customer Experience (CX)
Customer Experience (CX)
Ramadan Babers, PhD
 
Python lec 1004_ch02_excercies
Python lec 1004_ch02_excerciesPython lec 1004_ch02_excercies
Python lec 1004_ch02_excercies
Ramadan Babers, PhD
 
Python lec 1002_for_biologists
Python lec 1002_for_biologistsPython lec 1002_for_biologists
Python lec 1002_for_biologists
Ramadan Babers, PhD
 
Python lec 1001_for_biologists
Python lec 1001_for_biologistsPython lec 1001_for_biologists
Python lec 1001_for_biologists
Ramadan Babers, PhD
 
Db lec 08_new
Db lec 08_newDb lec 08_new
Db lec 08_new
Ramadan Babers, PhD
 

More from Ramadan Babers, PhD (20)

Part10 finance investment limitations of ratio analysis
Part10 finance investment limitations of ratio analysisPart10 finance investment limitations of ratio analysis
Part10 finance investment limitations of ratio analysis
 
Part09 finance investment ratio analysis investment ratio
Part09 finance investment ratio analysis investment ratioPart09 finance investment ratio analysis investment ratio
Part09 finance investment ratio analysis investment ratio
 
Part08 finance investment ratio analysis solvency ratio
Part08 finance investment ratio analysis solvency ratioPart08 finance investment ratio analysis solvency ratio
Part08 finance investment ratio analysis solvency ratio
 
Part07 finance investment ratio analysis profitability ratio
Part07 finance investment ratio analysis profitability ratioPart07 finance investment ratio analysis profitability ratio
Part07 finance investment ratio analysis profitability ratio
 
Part06 finance investment ratio analysis efficiency ratio
Part06 finance investment ratio analysis efficiency ratioPart06 finance investment ratio analysis efficiency ratio
Part06 finance investment ratio analysis efficiency ratio
 
Part05 finance investment_ratio_analysis_liquidity_ratio_presentation
Part05 finance investment_ratio_analysis_liquidity_ratio_presentationPart05 finance investment_ratio_analysis_liquidity_ratio_presentation
Part05 finance investment_ratio_analysis_liquidity_ratio_presentation
 
Part04 finance investment_ratio_analysis_introduction_presentation
Part04 finance investment_ratio_analysis_introduction_presentationPart04 finance investment_ratio_analysis_introduction_presentation
Part04 finance investment_ratio_analysis_introduction_presentation
 
Part03 finance investment_financial_statement_analysis_presentation
Part03 finance investment_financial_statement_analysis_presentationPart03 finance investment_financial_statement_analysis_presentation
Part03 finance investment_financial_statement_analysis_presentation
 
Part02 finance investment_finance_and_financial_reporting_presentation
Part02 finance investment_finance_and_financial_reporting_presentationPart02 finance investment_finance_and_financial_reporting_presentation
Part02 finance investment_finance_and_financial_reporting_presentation
 
Part01 finance investment_basics_presentation
Part01 finance investment_basics_presentationPart01 finance investment_basics_presentation
Part01 finance investment_basics_presentation
 
Strategic Management part_03_03
Strategic Management part_03_03Strategic Management part_03_03
Strategic Management part_03_03
 
Strategic Management part_02_03
Strategic Management part_02_03Strategic Management part_02_03
Strategic Management part_02_03
 
Strategic Management part_01_03
Strategic Management part_01_03Strategic Management part_01_03
Strategic Management part_01_03
 
Customer Experience (CX) updated version V9.0
Customer Experience (CX) updated version V9.0Customer Experience (CX) updated version V9.0
Customer Experience (CX) updated version V9.0
 
Classification using decision tree in detail
Classification using decision tree in detailClassification using decision tree in detail
Classification using decision tree in detail
 
Customer Experience (CX)
Customer Experience (CX)Customer Experience (CX)
Customer Experience (CX)
 
Python lec 1004_ch02_excercies
Python lec 1004_ch02_excerciesPython lec 1004_ch02_excercies
Python lec 1004_ch02_excercies
 
Python lec 1002_for_biologists
Python lec 1002_for_biologistsPython lec 1002_for_biologists
Python lec 1002_for_biologists
 
Python lec 1001_for_biologists
Python lec 1001_for_biologistsPython lec 1001_for_biologists
Python lec 1001_for_biologists
 
Db lec 08_new
Db lec 08_newDb lec 08_new
Db lec 08_new
 

Recently uploaded

A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
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
 
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
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
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
 
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
 
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)
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
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
 
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
 
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
 
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
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
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
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 

Recently uploaded (20)

A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
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
 
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
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
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
 
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
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
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
 
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
 
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
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
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...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 

Python lec 1003_for_biologists

  • 1. + Dr. Ramadan Babers Faculty of Science - Helwan University Spring – 2019 Python LEC - 03 for Biologists https://www.linkedin.com/in/ramadan-babers-phd-78976345
  • 3. 3 Storing strings in variables We can take a string and assign a name to it using an equals sign – we call this a variable: We can use the variable name instead of the string itself – for example, we can use it in a print statement
  • 4. 4 Storing strings in variables variable names are arbitrary – that means that we can pick whatever we like to be the name of a variable. variable names are case-sensitive,so  my_dna,  MY_DNA,  My_DNA and  My_Dna are all separate variables.
  • 5. 5Tools for manipulating strings 1- Concatenation We can concatenate (stick together) two strings using the + symbol1 .This symbol will join together the string on the left with the string on the right:
  • 6. 6Tools for manipulating strings 1- Concatenation (cont.) use variables that point to strings: join multiple strings together in one go: concatenation inside a print statement:
  • 7. 7Tools for manipulating strings 2- Finding the length of a string useful built-in tool in Python is the len function (len is short for length). No output appears Why ?????? we need to store it in a variable
  • 8. 8Tools for manipulating strings 2- Finding the length of a string Python treats strings and numbers differently. len function: the result (or return value) is not a string, it's a number. calculates the length of a DNA sequence and then prints a message telling us the length: my_dna = "ATGCGAGT" dna_length = len(my_dna) print("The length of the DNA sequence is " + dna_length)
  • 9. 9Tools for manipulating strings 2- Finding the length of a string Python has a built-in solution – a function called str which turns a numberinto a string so that we can print it.
  • 10. 10Tools for manipulating strings 3- Changing case A method is like a function, but instead of being built in to the Python language, it belongs to a particular type. Method & Function Ex. lower and upper are belong to the string type.
  • 11. 11Tools for manipulating strings 3- Changing case (Quiz) Upper case: ATGC Lower case: atgc Write a python code that print the sequence of DNA “ATGC” in lower and upper case. The result will as shown below.
  • 12. 12Tools for manipulating strings 4- Replacement it takes two arguments (both strings) and returns a copy of the variable where all occurrences of the first string are replaced by the second string. replace method replace("v", "y") replace("vls", "ymt") the original variable
  • 13. 13Tools for manipulating strings 5- Extracting part of a string If we want a short portion of a long string, this is known as taking a substring. To get it, we follow the variable name with a pair of square brackets which enclose a start and stop position, separated by a colon (:). protein = "vlspadktnv" print(protein[3:5]) print(protein[0:6]) print(protein[0:60])
  • 14. 14Tools for manipulating strings 6- Counting and finding substrings A very common job in biology is to count the number of times some pattern occurs in a DNA or protein sequence. counting the number of times a substring occurs in a string. method that does the job is called count
  • 15. 15Tools for manipulating strings 6- Counting and finding substrings Count Example
  • 16. 16Tools for manipulating strings 6- Counting and finding substrings find method takes a single string argument, just like count, and returns a number which is the position at which that substring first appears in the string the index of the substring
  • 17. 17Tools for manipulating strings 6- Counting and finding substrings Find Example What is this?