Python-Course

Crash Course in Python with an Introduction to Linux for absolute beginners

View on GitHub

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

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

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

  1. cd
  2. pwd
  3. ls

Python Commands

  1. print()
  2. input()
  3. str()
  4. int()
  5. float()
  6. import
  7. sqrt()
  8. exit()