LAB 11 Pfund

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

USAMA MEHBOOB ROLL NO 2022F-SE-225

SECTION E
LAB # 11
MODULES AND PACKAGES
OBJECTIVE:
Getting familiar with the environment for using modules and packages.
A. Point out the errors, if any, and paste the output also in the following Python programs.
1. Code:
import sys as s
print(sys.executable)
print(sys.getwindowsversion())
ERROR:

Write s instead of sys in line 2 and line 3

CORRECT CODE:

OUTPUT:
USAMA MEHBOOB ROLL NO 2022F-SE-225
SECTION E
2. CODE:

import datetimethe number of seconds


# Returns
from print(time.time())
datetime import date
import times a number of seconds to a date object
#Converts
# Returns the number of seconds
print(datetime.datetime.now())
print(time.time())
# Converts a number of seconds to a date object
print(datetime.datetime.now())

ERROR:
In line 3 there is no module name times.

CORRECT CODE:

OUTPUT:
USAMA MEHBOOB ROLL NO 2022F-SE-225
SECTION E
3. CODE:
From math import math
# using square root(sqrt) function contained
print(Math.sqrt(25))
print(Math.pi)
# 2 radians = 114.59 degrees
print(Math.degrees(2))

ERROR:
Remove from math from line 1
Write small m in math in all print lines

CORRECT CODE:

OUTPUT:
USAMA MEHBOOB ROLL NO 2022F-SE-225
SECTION E
B. What would be the output of the following programs:
1. CODE:

OUTPUT:

2. CODE:

OUTPUT:
USAMA MEHBOOB ROLL NO 2022F-SE-225
SECTION E
3. CODE:

OUTPUT:
USAMA MEHBOOB ROLL NO 2022F-SE-225
SECTION E

C. Write Python programs for the following:


1. Write a NumPy program to create an 1D array of 10 zeros, 10 ones, 10 fives.
CODE:

OUTPUT:

2. Write a NumPy program to create a 3x3 matrix with values ranging from 2 to 10.
CODE:

OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy