Two ways of importing modules in Python¶
In [8]:
import random
print(random.randint(1,10))
In [6]:
from random import *
print(randint(1,10))
We can import many modules in a same line¶
In [2]:
import random, sys, math
Early exit : Use sys.exit() to early exit the program¶
In [3]:
print("Hello")
sys.exit()
print("Good bye")
In [5]:
import pyperclip
Copy and paste using pyperclip module¶
In [7]:
pyperclip.copy("Hello Worldss")
print(pyperclip.paste())
Print returns NONE Type¶
Every function has a return value. If it doesn't return anything, then probably it's return type is NONE
In [9]:
print(type(print("Arun")))
Keyword arguement in functions¶
In [10]:
print("Hello")
print("World")
In [14]:
print("Hello", end = " ")
print("World")
In [15]:
print("apple","orange","mango")
In [16]:
print("apple","orange","mango", sep = "")
In [17]:
print("apple","orange","mango", sep = "-")
No comments :
Post a Comment