Skip to content

Instantly share code, notes, and snippets.

View ChaitanyaBaweja's full-sized avatar

Chaitanya Baweja ChaitanyaBaweja

View GitHub Profile
import math
# Initializing a variable with positive infinity
positive_inf = math.inf
print('Positive Infinity: ', positive_inf)
# Initializing a variable with negative infinity
negative_inf = -math.inf
print('Negative Infinity: ', negative_inf)
# Initializing a variable with positive infinity
positive_inf = float('inf')
print('Positive Infinity: ', positive_inf)
# Initializing a variable with negative infinity
negative_inf = float('-inf')
print('Negative Infinity: ', negative_inf)
%%html
<html>
<body>
<h3>Student Marks</h3>
<table>
<tr>
<th>Name</th>
<th>Roll</th>
<th>Age</th>
<th>Marks</th>
roll_number = 12
name = 'Chaitanya Baweja'
age = 14
%who
# Output
# age name roll_number
%%writefile -a my_file.py
# Function to return diff of two numbers
def diff_num(a,b):
return a-b
%%writefile my_file.py
# Function to return sum of two numbers
def sum_num(a,b):
return a+b
def hello():
print('Hello Chaitanya')
hello()
# Importing required libraries
import urllib.request
# Adding information about user agent
opener=urllib.request.build_opener()
opener.addheaders=[('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1941.0 Safari/537.36')]
urllib.request.install_opener(opener)
# setting filename and image URL
filename = 'sunshine_dog.jpg'
# importing required modules
import urllib.request
# setting filename and image URL
filename = 'sunshine_dog.jpg'
image_url = "https://cdn.pixabay.com/photo/2020/02/06/09/39/summer-4823612_960_720.jpg"
# calling urlretrieve function to get resource
urllib.request.urlretrieve(image_url, filename)
# First import wget python module.
import wget
# Set up the image URL
image_url = "https://cdn.pixabay.com/photo/2020/02/06/09/39/summer-4823612_960_720.jpg"
# Use wget download method to download specified image url.
image_filename = wget.download(image_url)
print('Image Successfully Downloaded: ', image_filename)