several cs101 tas and cse staff cs 101cs101/labs/lab01.pdf · system, an alternative to windows and...

21
CS 101 Computer Programming and Utilization Bharat with several CS101 TAs and CSE staff Course webpage: https://www.cse.iitb.ac.in/~cs101 / Lab1: Getting Started Clip art and quote credits: Various sources found through Google Image Search

Upload: others

Post on 17-Mar-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

CS 101 Computer Programming

and Utilization

Bharatwith

several CS101 TAs and CSE staff

Course webpage: https://www.cse.iitb.ac.in/~cs101/

Lab1: Getting Started

Clip art and quote credits: Various sources found through Google Image Search

Page 2: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Goals of this lab

• The goal of this lab is to become familiar with the following:– Ubuntu navigation

– Basic usage of bash/terminal

– Web browser, text editor

– Bodhitree interface

– Files, directories, web pages

– Codeblocks, s++

Spring 2019 CS101@CSE IIT Bombay07/25/19 2

Page 3: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Login into Lab Machines

• You will see a screen similar to this• Press enter key on your keyboard• Enter the following password

labuser

• Click Unlock.

• You will see ubuntu desktop

screen. Ubuntu is an operating

system, an alternative to

Windows and Mac

Spring 2019 CS101@CSE IIT Bombay07/25/19 3

Page 4: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Ubuntu Navigation and Directories

• You will see some icons on the left of your desktop• Click on ‘Files’ icon. • A window will open up.• This shows ‘Home’ directory• You can see some folders• Currently, ‘Home’ is selected

• Click ‘Downloads’• All files that you download

from the internet will goin this folder

Spring 2019 CS101@CSE IIT Bombay07/25/19 4

Show Applications Icon

Page 5: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Files

Spring 2019 CS101@CSE IIT Bombay07/25/19 5

• Way of storing information in various formats• Files are stored in a directory/folders• Different file formats have different extensions • Example

○ Text: .txt, .c, .cpp, .py○ Word: .doc, .docx○ Document: .pdf○ Excel: .xls, .xlsx○ Libre Writer: .odt○ Libre Impress: .odp○ Images: .png, .jpg, .bmp○ Video: .mp4, .ogg○ Audio: .wav, .mp3

Page 6: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Text editor

• A software in which you are able to write, save, cut, copy, paste, etc. Examples (gedit, vi, etc.)

• Open gedit by clicking ‘Show Applications icon’, type ‘gedit’, select. You will see a new file opened up. Write something into the file. Click ‘Save’

• Write your filename and click ‘Save’ (green button)

Spring 2019 CS101@CSE IIT Bombay07/25/19 6

Page 7: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Text editor

● The saved file will look like below

● Click on the 3 horizontal lines, and explore the options

Spring 2019 CS101@CSE IIT Bombay07/25/19 7

Page 8: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Text editor

● Locate the file in the directory● Click on Files folder ● You will be in the home directory.● Select the text file you just created, myfirstfile.txt● Press Ctrl + c ● Press Ctrl + v ● A new file will be created● Double click to open the new file● You will see the same content that you wrote● Change some text and save it. (Ctrl + s)● Now open the original file (myfirstfile.txt)● You will see that the original file is not changed

Spring 2019 CS101@CSE IIT Bombay07/25/19 8

Page 9: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Web browser

• An application using which we can view the information given on the web (news, sports, songs, movies, etc.)

• Google Chrome, Mozilla Firefox, Safari, etc.

• Click ‘Show Applications’ icon

– located in the bottom left

• Type Google chrome and click on the icon

• The browser will open up

• It will look similar to this

Spring 2019 CS101@CSE IIT Bombay07/25/19 9

URL bar

Page 10: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Basic Shell commands (Terminal)

Spring 2019 CS101@CSE IIT Bombay07/25/19 10

• Press Ctrl + Alt + t. A terminal opens up.• Write pwd and press enter (print working directory)

○ It shows your current folder path• Write ls and press enter

○ It lists the files and folders in your current folder• Write mkdir test and press enter (make directory)

○ Creates a folder called test• Write cd test and press enter(change directory)

○ Changes your directory to test• Write cd .. and press enter (go one level up)

○ Takes you one level up• Write cp myfirstfile.txt second.txt

○ Creates second.txt with the contents of myfirstfile.txt

Page 11: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Code::Blocks

• An IDE for compiling and executing C/C++ programs• Click and type codeblocks. Click• You will first see Simple::Blocks screen

• A new window will open. • Select GCC with simpleCPP • Click Ok• This screen appears only once• You may or may not get

this screenSpring 2019 CS101@CSE IIT Bombay07/25/19 11

Page 12: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Code::Blocks (Basic Program)

• Save the file• as hello.cpp • in your home directory• Write the following after main_program{

○ cout << “hello”;• Click Build and run• A new window opens up

Spring 2019 CS101@CSE IIT Bombay07/25/19 12

cout << “hello”;

Page 13: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Code::Blocks (Graphics Program 1)

Spring 2019 CS101@CSE IIT Bombay07/25/19 13

• Create a new file called “square.cpp” in your home directory and write the following program in it.

• Play around with the code as you want andsee what happens.

Page 14: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Code::Blocks (Graphics Program 2)

Spring 2019 CS101@CSE IIT Bombay07/25/19 14

• Create a new file called “polygon.cpp” in your home directory and write the following program.

• Instructions forrunning the code arein the next slide

Page 15: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

s++ (Simplecpp)

Spring 2019 CS101@CSE IIT Bombay07/25/19 15

• Press Ctrl + Alt + t. A terminal opens up.• Write ls and press enter• You will see the file ‘polygon.cpp’, and possibly some

other existing files• Write: s++ polygon.cpp• Press enter. This will compile the program• Write: ./a.out • Press enter. This will execute the program.• Write 5 on the terminal• Press enter• The turtle simulator will open up showing a pentagon• Try running “a.out” again with different values (6,7, etc).

Page 16: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Preparing for upload

• Click on Files folder• Create a new folder (Right click > New Folder)• Write your roll number as the folder name• Copy only hello.cpp, square.cpp, and polygon.cpp in this

folder• Do NOT copy any other file• Right click on the folder > Click compress > Create• A new file will be created which will be similar to:

○ Rollnumber.zip

Spring 2019 CS101@CSE IIT Bombay07/25/19 16

Page 17: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Bodhitree (http://cs101.bodhi.cse.iitb.ac.in/)

• All lab related activity will happen on this interface, such as submissions, evaluations, etc.

• Accounts have already been created for everyone, with your Roll Number as the user ID as well as the password.

• After the first login, please change the password to something you can remember.

• You have been enrolled in “CS101 Winter 2020” course automatically. This is the page for the course.

• Detailed steps are on the next slides

Spring 2019 CS101@CSE IIT Bombay07/25/19 17

Page 18: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Webmail

• Open your webmail (webmail.iitb.ac.in)

Autumn 2019 CS101@CSE IIT Bombay07/25/19 18

• You would have received the email similar to this one.

• Click on the link given in the email

Page 19: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Bodhitree

• Create a password for your account. Click ‘Submit’

• You will see CS101 Winter 2020 listed. Click on the link and explore

Autumn 2019 CS101@CSE IIT Bombay07/25/19 19

Page 20: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Assignments• As a part of this lab, you need to submit the .zip file (containing the

3 programs) which you just created

Login into http://cs101.bodhi.cse.iitb.ac.in/

■ Select CS101 Winter 2020 → Programming Assignments

■ Click Lab 1 → Choose file → Double click the .zip file you just created (YourRollNo.zip) → Upload

■ Click Run Practice Test case

Autumn 2019 CS101@CSE IIT Bombay07/25/19 20

Page 21: several CS101 TAs and CSE staff CS 101cs101/labs/Lab01.pdf · system, an alternative to Windows and Mac ... Changes your directory to test • Write cd .. and press enter (go one

Homework / Extra work

• Try out simplecpp programs done in the class

Spring 2019 CS101@CSE IIT Bombay07/25/19 21