Docsity

Python programming basic codes, Study notes of Computer Programming

Toggle sidebar
bg1
INDEX
Sr. no. Title Date Remarks
1 Introduction to Python and
Datatypes
04-02-26
2 Python Fundamentals 11-02-26
3 Python Fundamentals 18-2-26
4 Python Fundamentals 25-02-26
5 Python Fundamentals 25-2-2026
6 Python Fundamentals 4-03-26
7 Python Fundamentals 11-03-26
8 Data Structures 18-03-26
9 Data Structures 1-04-26
10 Data Structures 8-04-26
11 Data Structures 15-04-26
12 Data Structures 22-04-26
13 File Handling 29-04-26
14 Advanced Python
Development of Graphical
User Interface by Tkinter
6-05-26
12 Advanced Python Database
connectivity
6-05-26
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26

Partial preview of the text

Download Python programming basic codes and more Study notes Computer Programming in PDF only on Docsity!

INDEX

Sr. no. Title Date Remarks 1 Introduction to Python and Datatypes 04-02- 2 Python Fundamentals 11-02- 3 Python Fundamentals 18-2- 4 Python Fundamentals 25-02- 5 Python Fundamentals 25-2- 6 Python Fundamentals 4-03- 7 Python Fundamentals 11-03- 8 Data Structures 18-03- 9 Data Structures 1-04- 10 Data Structures 8-04- 11 Data Structures 15-04- 12 Data Structures 22-04- 13 File Handling 29-04- 14 Advanced Python Development of Graphical User Interface by Tkinter 6-05- 12 Advanced Python Database connectivity 6-05-

LIST OF PROGRAMS PERFORMED

  1. Write a python program to add two dna seq length by taking user input
  2. Python program to add molecular weight of proteins
  3. Python program to convert the poły a taił of dna into upper case
  4. Python program to convert the active site region of a protein into lower case.
  5. Python program to label a DNA polymerase enzyme.
  6. Python program to count the number of valine in the given protein.
  7. Python program to find whether the given protein sequence ends with glycine.
  8. Python program to find whether the given protein sequence starłs with with
  9. Python program to find whether the given DNA sequence has thymine and alanine.
  10. Python program to concatenate a protein sequence and iłs molecular weight by format method()
  11. Python program to find whether the give protein sequence has the presence of active site(GAGAGA)
  12. Python program to find whether the give protein ACCESSION ID AND NUMBERS AND CHARACTERS
  13. Python program to find whether the given protein sequence is masked for BLAST (ISALPHA)
  14. Python program to find whether the given string has numbers
  15. Python program to find whether the given string has valid identifiers.
  16. Write a python program to demonstrate arithmetic operators. operators.
  17. W.A.P to calculate the GC content of a DNA sequence.
  18. W.A.P to calculate the number of nucleotides of a Zika DNA segment.
  19. W.A.P to demonstrate the use of comparison operators. (Take Two DNA strings as input and do the comparison)
  20. W.A.P to concatenate two parts of protein sequence into one single sequence. String Function
  21. W.A.P to demonstrate the use of relational operators. relational operators
  22. W.A.P to take a DNA sequence in lower case,convert ił to upper case and print the second and last nucleotide , and first and last codon of the sequence.
  23. W.A.P to initialize a green fluorescence protein , first four codons and RNA sequence for GFP and concatenate several codons coding for GFP protein.
  24. Initialize a Human D-Loop and print ił. Initialize the sub-string to be searched. (Example :CAT), Extract the first and second codon after the sub-string,next to last and last).
  25. W.A.P to demonstrate the use of logical operators
  26. W.A.P to demonstrate the use of membership operators
  27. W.A.P to demonstrate the use of identity operators
  28. W.A.P to find whether the given DNA sequence has start codon (slice a codon from 0: first and assign it to a variable)
  29. W.A.P to find whether the given protein has a signal peptide region ((slice a signal peptide region Eg. from 0:7 first and assign it to a variable)
  30. W.A.P to find if the last codon in a DNA segment is the start codon ATG or one of the stop codons TAA, TAG, or TGA or none of the above.
  1. Write a Python function program for Beer-Lambert law.
  2. Write a Python function program for enzyme reaction rate calculation.
  3. Write a Python function program to calculate the protein concentration.
  4. Write a Python function program to calculate DNA/RNA concentration. 63. Write a Python function Python function program to calculate molarity.
  5. Write a Python function program to calculate dilution.
  6. Write a program to open a file in python.
  7. WAP to open a file in read mode.
  8. WAP to demonstrate with() in python.
  9. WAP to illustrate read mode character wise.
  10. WAP to create a file using the write function.
  11. Write a program to create the application main window using Tkinter.
  12. Write a program to create a simple button application using Tkinter.
  13. Write a program to create Four buttons and show information on any one button clicked using Tkinter.
  14. Write a program to create application to demonstrate Pack method() using
  15. Write a program to create application to demonstrate Grid method() using
  16. Write a program to create application to demonstrate Place method() using Tkinter.
  17. Write a program to create GUI for Molarity calculation
  18. Write a program to create GUI for calculation of Hydrophobic amino acids
  19. Write a program to create GUI for an Enzyme Simulator
  20. Write a program to create GUI for an GC percentage calculator 80. Write a program to create a Checkbutton application using Tkinter.
  21. Write a program to create a Radiobutton application using Tkinter.
  22. Write a program to create a database using Python Database Connectivity.

1. Write a python program to add two dna seq length by taking user input seq1=input('Enter first sequence:') seq2=input('Enter second sequence:') final_seq=seq1+seq2 print(final_seq) 2. Python program to add molecular weight of proteins mw1=int(input('Enter the molecular weight of first prorein:')) mw2=int(input('Enter the molecular weight of second prorein:')) mw3=int(input('Enter the molecular weight of third prorein:')) mw4=int(input('Enter the molecular weight of fourth prorein:')) mw=mw1+mw2+mw3+mw print(mw) 3. Python program to convert the poły a taił of dna into upper case poly_a_tail=input('Enter the sequence:') conv_poly_a_tail=poly_a_tail.upper() print(conv_poly_a_tail)

7. Python program to find whether the given protein sequence ends with glycine. protein_seq=input('Enter the sequence:') endswith_glycine=protein_seq.endswith('g') print(endswith_glycine) 8. Python program to find whether the given protein sequence starłs with with tryptophan and cysytine. protein_seq=input('Enter the protein sequence:') startswith_wc=protein_seq.startswith('WC') print(startswith_wc) 9. Python program to find whether the given DNA sequence has thymine and alanine. dna_seq=input('Enter the DNA sequence:') dna_seq_ta=dna_seq.find('t and a') print(dna_seq_ta)

10. Python program to concatenate a protein sequence and iłs molecular weight by format method() protein_sequence=input('Enter the protein sequence:') molecular_weight=input('Enter the molecular weight of the protein:') format_string=f'The protein sequence is {protein_sequence}, the molecular weight of the protein is {molecular_weight}' print(format_string) 11. Python program to find whether the give protein sequence has the presence of active site(GAGAGA) protein_seq=input('Enter the protein sequence:') active_site=protein_seq.find('gagaga')!=-1 print(active_site) 12. Python program to find whether the give protein ACCESSION ID AHS NUMBERS AND CHARACTERS accession_id=input('Enter the accession ID:') ac_id_isalnum=accession_id.isalnum() print(ac_id_isalnum)

16. Write a python program to demonstrate arithmetic operators. x=float(input('Enter a number:')) y=float(input('Enter another number:')) a=x+y print(a) b=x-y print(b) c=xy print(c) d=x/y print(d) e=x%y print(e) f=xy print(f) g=x//y print(g) 17. W.A.P to calculate the GC content of a DNA sequence. dna_sequence=input('Enter a dna sequence:') total_nucleotides=len(dna_sequence) g_content=dna_sequence.count('g') c_content=dna_sequence.count('c') gc_content=((g_content+c_content)/total_nucleotides) print(gc_content)

18. W.A.P to calculate the number of nucleotides of a Zika DNA segment. zika_dna_segment=input('Enter the Zika DNA segment:') number_of_nucleotides=len(zika_dna_segment) print(number_of_nucleotides) 19. W.A.P to demonstrate the use of comparison operators. (Take Two DNA strings as input and do the comparison) string_1=input('Enter the first string:') string_2=input('Enter the second string:') print(string_1==string_2) print(string_1!=string_2) print(string_1>string_2) print(string_1=string_2) print(string_1<=string_2)

22. W.A.P to take a DNA sequence in lower case,convert ił to upper case and print the second and last nucleotide , and first and last codon of the sequence. dna_sequence=input('Enter a dna sequence:') upper_dna_sequence=dna_sequence.upper() print('Second nucleotide:',upper_dna_sequence[1]) print('Last nucleotide:',upper_dna_sequence[-1]) print('First codon:',upper_dna_sequence[0:3]) print('Last codon:',upper_dna_sequence[-3:]) 23. W.A.P to initialize a green fluorescence protein , first four codons and RNA sequence for GFP and concatenate several codons coding for GFP protein. String codon_1='ATG' codon_2='ACG' codon_3='AAA' codon_4='AGC' codons_for_GFP=codon_1+codon_2+codon_3+codon_ print(codons_for_GFP)

24. Initialize a Human D-Loop and print ił. Initialize the sub-string to be searched. (Example :CAT), Extract the first and second codon after the sub-string,next to last and last). human_d_loop='ATGCATCGATCGTACCGACGGT' print(human_d_loop) sub_string=human_d_loop.find('CAT') print(sub_string) print(human_d_loop[6:9]) print(human_d_loop[9:12]) print(human_d_loop[-3:]) print(human_d_loop[-6:-3]) 25. W.A.P to demonstrate the use of logical operators x = 5 print(x > 3 and x < 10) x = 5 print(x > 3 or x < 4) x = 5 print(not(x > 3 and x < 10))

print('Yes') else: print('No')

29. W.A.P to find whether the given protein has a signal peptide region ((slice a signal peptide region protein_sequence=input('Enter the protein sequence:') sliced_protein_sequence=(protein_sequence[0:7]) if sliced_protein_sequence=='MWSTA': print('Yes') else: print('No') 30. W.A.P to find if the last codon in a DNA segment is the start codon ATG or one of the stop codons TAA, TAG, or TGA or none of the above. dna_sequence=input('Enter the DNA sequence:') codon=dna_sequence[-3:] if codon=='ATG': print('The last codon of the sequence is a start codon') elif codon in ['TAA','TAG','TGA']: print('The last codon of the sequence is a stop codon') else: print('None of the above')

31. W.A.P to prints out all codons starting with T. dna = input("Enter DNA sequence: ") print("Codons starting with T are:") for i in range(0, len(dna), 3): codon = dna[i:i+3] if len(codon) == 3 and codon.startswith('T'): print(codon) 32. W .A.P to create a sequence of numbers from 3 to 19 with incremenation of 2. seq_of_nos=[3,5,7,9,11,13,15,17,19] print(seq_of_nos) 33. W.A.P to create a list of codons coding for collagen protein. codons_for_collagen=input('Enter the codons for collagen:') print(codons_for_collagen)

37. W.A.P to add a codon to the list and remove a codon which is creating a genetic variation list dna_sequence=input('Enter the DNA sequence:').split() dna_sequence.insert(2,'ATT') print(dna_sequence) dna_sequence.remove('AGC') print(dna_sequence) 38. W.A.P to count the frequency of amino acid in the given protein sequence. protein_sequence=input('Enter the protein sequence:') frequency_of_amino_acid=protein_sequence.count('W') print(frequency_of_amino_acid) 39. Write a Python program to sum all the items in a list. a = [10, 20, 30, 40, 50] res = sum(a) print(res)

40. Write a Python program to get the protein highest molecular weight from a list. molecular_weight=input('Enter the molecular weights:').split() print(molecular_weight) highest_molecular_weight=max(molecular_weight) print(highest_molecular_weight) 41. Write a Python program to get the smallest number from a list. list_items=input('Enter the list items:').split() print(list_items) smallest_item=min(list_items) print(smallest_item) 42. Write a Python program to check if a list is empty or not list list_items=[] if not list_items: print('The list is empty') else: print('The list is not empty')