By liran bh | 1/4/2017 | Python

Python Simple ex.

1. Write a program called “print-two-args.py” that reads the first two command line arguments after the program name, stores their values as variables, and then prints them on the same line with a colon between.

 

> python print-two-args.py hello world

hello : world

 

2. Write a program called “add-two-args.py” that reads the first two command line arguments after the program name, stores their values as variables, and then prints their sum.

 

> python add-two-args.py 1 2

3.0

 

3. Write a program called dna2rna.py that reads a DNA sequence from the first command line argument, and then prints it as an RNA sequence. Make sure it works for both uppercase and lowercase input. (T/t à U/u)

 

> python dna2rna.py  AGTCAGT

ACUCAGU

> python dna2rna.py actcagt

acucagu

> python dna2rna.py ACTCagt

ACUCagu

 

4. Write a program get-codons.py that reads the first command line argument as a DNA sequence and prints the first three codons, one per line, in uppercase letters.

 

> python get-codons.py TTGCAGTCG

TTG

CAG

TCG

> python get-codons.py TTGCAGTCGATC

TTG

CAG

TCG

> python get-codons.py tcgatcgac

TCG

ATC

GAC

 

5. Write a program that reads a protein sequence as a command line argument and prints the location of the first cysteine residue ('C')

 

> python find-cysteine.py MNDLSGKTVIITGGARGLGAEAARQAVAAGARVVLADVLDEEGAATARELGDAARYQHLDVTIEEDWQRVCAYAREEFGSVDGL

70

 

> python find-cysteine.py MNDLSGKTVIITGGARGLGAEAARQAVAAGARVVLADVLDEEGAATARELGDAARYQHLDVTIEEDWQRVVAYAREEFGSVDGL

-1

{{CommentsModel.TotalCount}} Comments

Your Comment

{{CommentsModel.Message}}

Recent Stories

Top DiscoverSDK Experts

User photo
3355
Ashton Torrence
Web and Windows developer
GUI | Web and 11 more
View Profile
User photo
3220
Mendy Bennett
Experienced with Ad network & Ad servers.
Mobile | Ad Networks and 1 more
View Profile
User photo
3060
Karen Fitzgerald
7 years in Cross-Platform development.
Mobile | Cross Platform Frameworks
View Profile
Show All
X

Compare Products

Select up to three two products to compare by clicking on the compare icon () of each product.

{{compareToolModel.Error}}

Now comparing:

{{product.ProductName | createSubstring:25}} X
Compare Now