DOC PREVIEW
IIT Delhi COL 100 - Lab 1

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Introduction to ProgrammingLab 1January 2, 2017Part 1: Introduction to Linux1. Turn on your system and login using your kerberos login ID and password.2. Press Ctrl + Alt + T to open a terminal.3. Create a directory in your home folder (using mkdir) and name it as COL100. Type mkdir COL1004. Change the current directory to COL100. Type cd COL100.5. In this directory, create another folder, called as Lab1. Type mkdir Lab16. cd to Lab1. Type cd Lab1.7. Create a text file “a.txt” using gedit (type gedit a.txt) and write your name and entry number in it.Save it and close it.8. Copy the contents of ”a.txt” to ”b.txt” using cp. Type cp a.txt b.txt9. Open ”b.txt” and verify that it is a copy of ”a.txt”. Type gedit b.txt.10. List the contents of the directory Lab1 and learn how to recognize files and folders. Type ls.11. Rename ”b.txt” as ”acopy.txt” using mv. Type mv b.txt acopy.txt.12. Retrieve previous commands using the arrow keys.13. Move out of COL100 using .. Type cd ..14. Copy the directory hierarchy COL100 to COL100copy using cp -r. Type cp -r COL100 COL100copy.15. List the folder contents using ls. Type ls16. Delete the directory hierarchy COL100copy using rm and rm -r. Type rm -r COL100copy.17. List the folder contents using ls. Also find out what ls -a does. Type ls -a.18. Learn the meaning of .. and .19. Use man to learn about different commands. Type man ls.20. Open an internet browser and set the Automatic proxy configuration url to http://www.cc.iitd.ernet.in/cgi-bin/proxy.btech (or proxy.dual if you are a Dual Degree student).(For Firefox, open Options > Advanced > Network Tab > (Connection) Settings > Choose “Automaticproxy configuration” and set the URL)21. Using cd and ls, check the contents of various other directories.22. Change permissions for a file or folder using chmod.123. Explore the Linux file system and see what else is there on it. Use Google search to learn about thedirectories root (/), /etc/, /bin/.24. Explore the other processes running in the system and try killing some processes (using ”ps” and ”kill”).25. Open ”acopy.txt”, change the entry number slightly and observe the difference using diff.26. Learn about I/O redirection (using ”>” and ”|”).27. Learn about text search and manipulation (using ”grep”, ”sort”, ”uniq”, etc.)Useful Commands in Linux1. Open terminal: Ctrl + Alt + T2. Terminate current Linux command: Ctrl + C3. Make a new directory: mkdir dirname4. Copy: cp src dest5. Rename: mv originalname newname6. Delete: rm filename7. Change working directory: cd path8. List contents of a folder: ls9. List contents of a folder including hidden files: ls -a10. Print current directory: pwd11. Run a python code: python ./name.pyPart 2: Programming with Python Examples1. In a terminal, open a text file using gedit. Copy the program given below. Name it as hello.py and saveit.1 # He l l o World program in Python2 p r i n t ( ’ He llo , world ! ’ )To run it, type python ./hello.py into the terminal. You can also enter the python console using thepython command.2. Now, let us write a program to add two numbers:12 # S to r e i n put numbers3 num1 = inp u t ( ’ Enter f i r s t nu mber : ’ )4 num2 = inp u t ( ’ Enter second number : ’ )56 # Add two numbers7 sum = f l o a t (num1) + f l o a t (num2)89 # D i s play th e sum10 p r i n t ”The sum o f ” , num1 , ”and” , num2 , ” i s ” ,


View Full Document

IIT Delhi COL 100 - Lab 1

Download Lab 1
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lab 1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab 1 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?