From basics to advanced — Python at your fingertips.
# Printing a simple message
print("Welcome to InterviewZilla!")
""" Multi-line comment or docstring
Used for documentation """# Assigning values to variables
x = 10
name = "InterviewZilla"
active = True
print(name, "rocks!")# Assign multiple variables in one line
a, b, c = "Python", "Data", "InterviewZilla"
print(a, b, c)# Integer, Float, String, Boolean
num = 100
price = 99.9
brand = "InterviewZilla"
active = True
print(type(price))s = "interviewzilla"
print(s.upper()) # INTERVIEWZILLA
print(s.title()) # Interviewzillaname = "Om"
print(f"Hello {name}, Welcome to InterviewZilla!")topics = ["Python", "Spark"]
topics.append("InterviewZilla")
print(topics)python -m venv env
source env/bin/activatepip install requestsimport numpy as np
arr = np.array([1,2,3])
print(arr.mean())import pandas as pd
df = pd.DataFrame({"Brand":["InterviewZilla"]})
print(df)import requests
r = requests.get("https://api.github.com")
print(r.status_code) # 200 if successfulimport json
data = {"brand": "InterviewZilla"}
print(json.dumps(data))brand = "InterviewZilla"
print(f"Best brand: {brand}")s = "InterviewZilla"
print(s[:9]) # Interviewx = 10
print(type(x)) # pi = 3.14159
print(round(pi, 2)) # 3.14nums = [3,1,2]
print(sorted(nums))nums = [1,2,3]
print(list(map(lambda x: x*2, nums)))nums = [1,2,3,4]
print(list(filter(lambda x: x%2==0, nums)))for i in range(5):
print(i)help(len) # Shows documentation for len()print(dir(str)) # Lists all attributes of string classimport numpy as np
print(np.pi)with open("iz.txt") as f:
print(f.read())