You are on page 1of 3

Command line basics

To know the current directory – cd hit enter

Dir – gives you the contents present in the current directory

To enter into a sub directory type cd<space>name of the directory it will take you into that directory

If you want to go back to the prev. directory type cd<space>..

Hitting tab can autocomplete the directories u r looking for

Cls is used to clear the entire command line screen

__________________________________________________________________________________

Python data type & variables –

numbers – int and float ;

String(str)-characters in single quote or double quote-eg:’hello’,”hello”,”I don’t do that” the usage


of having both single and double quote is tat in characters were we hav single quotes like the don’t
in the 3rd eg then the usage of double quotes helps differentiate it . strings are characters in ordered
sequences - we can use indexing or slicing to convey it .

Typically indexing is used when we ned to return a single character - in index [ ] are used and each
character returns a specific index value eg :

Character : h e l l o

Index : 0 1 2 3 4 such that [3] gives l … there is also reverse indexing

Reverse : 0 -4-3-2-1 it can be used when we don’t know the length of the character but we want
to obtain the last or penultimate chars.

Slicing : - typically used to grab a subsection of a string so typically used in returning more than one
character . the syntax for slicing is as follows [start:stop:step]

Where start is the starting index value i.e from which char u want to start grabbing

Stop is slightly different stop is the index value of the char until which u wanto grab but not including
that char so the o/p gives char from starting index to the one just before the stoping index.

Then there is the 3rd parameter step . it specifies how much jump it should make to get the next
character.. [ : : 2] implies give o/p as after 1st char jump to the 2nd char after the first then again to
the 2nd after that

In python strings cnnot be reassigned using indexes for eg : if name = ‘sam’ and we want to change it
to ‘pam’ we need to change s to p only ,so if we think name[0]=’p’ that is change the value of string
at index 0 in name to ‘p’ ..it will only give an error not the result pam.some other functions can give
you character reassignment which we will look into later.
Python has Dynamic typing variables compared to some other languages such as c or c++ which has
Static Typing Variables .. this means that when a variable is assingned a value for eg : a=2 in python
later in code the integer type value can be changed and given another data type value like a list for
eg : a = [“cricket”,”football”] and the python code will not show any error …but in case of lamguages
like c we first assign the variable to be an int datatype eg : int a=2 … so the value cannot be later
changed in the code .

There are pros and cons to Dynamic typing : pros – makes it easy to work with and becomes easy to
read the code …cons – can produce bugs since different data types are in play .so should be aware of
the types() in python.

TOPICS – PYTHON

**** NUMBERS****

1.) Types of Numbers in Python

2.) Basic Arithmetic

3.) Differences between classic division and floor division

4.) Object Assignment in Python

**** DYNAMIC TYPING ****


Python uses dynamic typing, meaning you can reassign variables to different data types. This
makes Python very flexible in assigning data types; it differs from other languages that
are statically typed.

**** TYPES OF VARIABLES ****

 int (for integer)
 float
 str (for string)
 list
 tuple
 dict (for dictionary)
 set
 bool (for Boolean True/False)

**** STRING ****

INDEXING; SLICING; STEP SIZE


It's important to note that strings have an important property known as immutability. This means
that once a string is created, the elements within it can not be changed or replaced. Something
we can do is concatenate strings

You might also like