Day-1 Day-2 Day-3 Day-4 Day-5 Day-6 Day-7 Day-8
Getting Started with Linux
Linux is an Open Source Operating System widely used for various purposes including scientific computing. To jump start the learning we will use the following commands and then understand its purpose.
$ls
$pwd
$cd
A folder is called directory in linux.
ls - list the contents
pwd - present working directory
cd - change directory
Getting Started with Python
Any program that we run, ultimately gives some information back. This is made visible with the help of print() function in python3.
Displaying output
print("Hello World")
In the above print(“Hello World”) function
- print is called the name of the function
- “Hello World” is called the value given to the function.
Getting Input from the user
The next function that we will learn about is called input(). Getting input from the user makes the program interactive and is often useful and/or fun.
name = input("Whats you name?\n")
Here the “variable” name stores the value from the user.
name = "Dinosaur"
print("Hello" + name)
print("Hello" + " " + name)
HelloDinosaur
Hello Dinosaur
Notice the difference in the above example.
To exit from python, use the function exit().
Data Types
The three basic data types that we will frequently use are
- String used as str() - Any character or sentence.
- Integer used as int() - Integers only.
- Float used as float() - Numbers with decimal points.
Challenge 1.
Get two numbers from the user. Given these two numbers are two sides of a right angle triangle. Calculate the hypotenuse.
Hint: Use math module as import math and sqrt() function
Summary of Day 1:
Linux Commands
- cd
- pwd
- ls
Python Commands
- print()
- input()
- str()
- int()
- float()
- import
- sqrt()
- exit()