0% found this document useful (0 votes)
5 views

Python

The document provides a concise overview of various Python concepts including exponentiation, string handling, lists, tuples, sets, and dictionaries. It explains the mutability of lists and dictionaries, the immutability of tuples, and the unique characteristics of sets. Additionally, it covers data types and methods for creating arrays using the NumPy library.

Uploaded by

Vinod
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python

The document provides a concise overview of various Python concepts including exponentiation, string handling, lists, tuples, sets, and dictionaries. It explains the mutability of lists and dictionaries, the immutability of tuples, and the unique characteristics of sets. Additionally, it covers data types and methods for creating arrays using the NumPy library.

Uploaded by

Vinod
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Python

1. How to write 2 to power 6?


2**6
2. How to ignore special meaning in python?
Give \ before that

3. How to print same word multiple time

4. How to cancel special meaning of \ ?


Write r before the statement it will ignore the special meaning of \

5. How to use the previous output value


Give _ in place it will take the previous output.

6. Printing of variable
Python

>In python string value cannot be changed.


>In python Array list can have different type of data.

>One or more List can be assigned to another list.

>List are mutable means we can change the value.


7. Performing different operation on List
Python

8. Tuples: it’s almost same as List we can have collection of values


here. Tuple is immutable that means here in Tuple we can not change
the values. In we give round bracket while declaring the values.
Tup=(21,36,14,25)
i)since we don’t change values in tuple so iteration is faster than list
9. SET: it is also same as list as it sores the collection of values the
difference is it does not maintain the sequence bcoz of which it does
not support indexing also it does not support duplicate values in it. If
we enter any duplicate value it will store only one.
Set={25,12,15,98}
10. Dictionary : a dictionary is a data structure that stores data in key-
value pairs. It's a built-in data type that's also known as a "dict".

Keys are unique identifiers for items.


Values are the data associated with those keys.
Keys can be strings, numbers, or tuples.
Values can be any type, including lists or other dictionaries.
Dictionaries are mutable, meaning they can be changed after they are created.
Dictionaries are unordered, meaning the items are not stored in any order.
Python

11. Data Type: Numeric:- int, float ,complex(an imaginary number),


Boolean
Sequence:- List, Tuple, set, String , range
Dictionary
12. Import math as m

From math Import sqrt,pow

Math is a module where we have all mathematical functions.


X=math.sqrt(25)
Python

13. Creating an array.

14. Ways of creating an array:-


Need to import Numpy-
array() - arr = array([1,2,3,4,5]) and arr = array([1,2,3,4,5],int)
print(arr.dtype) – to know the data type of array
linspace() – arr = linspace(0,15,16) -start from 0 will go till 15 and break
it into 16 parts
rr1 = linspace(0,15) By default it will break into 50 parts
it will be of folat type only
Python

arange() arr = arange(1,15,2) it will start from 1 go till 14 with a gap


of 2 in between

logspace() arr = logspace(1,40,5) with base of 10 will start from 1 to


40 in 5 parts

zeros()

ones()

You might also like