Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
36 views

DSE Lab Assignment 01.ipynb

The document contains a Python program assignment submitted by a student named Satyam Panjiyar from the 3rd year Petroleum Engineering batch. The assignment includes 3 questions - 1) creating a dictionary of student names and marks and printing their grades, 2) creating a 1D array of numbers from 0 to 9, and 3) creating a 3x4 matrix filled with values from 10 to 21. For question 1, the student inputs the number of students, their names and marks, creates a dictionary and prints the grades. For question 2, the student creates the array using numpy's arange() and array(). For question 3, the student creates the matrix using numpy's arange() and reshape().

Uploaded by

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

DSE Lab Assignment 01.ipynb

The document contains a Python program assignment submitted by a student named Satyam Panjiyar from the 3rd year Petroleum Engineering batch. The assignment includes 3 questions - 1) creating a dictionary of student names and marks and printing their grades, 2) creating a 1D array of numbers from 0 to 9, and 3) creating a 3x4 matrix filled with values from 10 to 21. For question 1, the student inputs the number of students, their names and marks, creates a dictionary and prints the grades. For question 2, the student creates the array using numpy's arange() and array(). For question 3, the student creates the matrix using numpy's arange() and reshape().

Uploaded by

Satyam Panjiyar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

8/27/22, 11:02 PM DSE Lab Assignment 01.

ipynb - Colaboratory

NAME - SATYAM PANJIYAR

ROLL NO. - 21

BATCH - F

CLASS - 3rd YEAR PETROLEUM ENGG.

(DSE LAB ASSIGNMENT 01)

Q 1. Write a python program to create a dictionary which contains student’s names and marks. Iterate over the
dictionary and apply below conditions to print their grades: a. Marks greater than or equal to 70 – Distinction b.
Marks between 60-69 – First Class c. Marks between 50-59 – Second Class d. Marks between 40-49 –Pass e.
Marks less than 40 - Fail

students = dict()
n = int(input("Enter Number of Students : ")) #taking input from user
for i in range(n): #running for loop for n inputs
        sname = input("Enter Name of Student : ")
        mark = int(input("Enter Marks : "))
        students[sname] = mark
print("\nDictionary of Student Created :")
print(students)
for i,j in students.items(): #i for name & j for marks
  if j<40:
    print("")
    print(i,'- Fail',[j])
  elif j in range(40,50): # 50 is excluded
    print("")
    print(i,'- Pass',[j])
  elif j in range(50,60): # 60 is excluded
    print("")
    print(i,'- Second Class',[j])
  elif j in range(60,70): #70 is excluded
    print("")
    print(i,'- First Class',[j])
  elif j>=70:
    print("")
    print(i,'- Distinction',[j])

Enter Number of Students : 6

Enter Name of Student : Ram

Enter Marks : 92

Enter Name of Student : Akshat

Enter Marks : 68

Enter Name of Student : Abhishek

Enter Marks : 54

Enter Name of Student : Nitish

Enter Marks : 44

Enter Name of Student : John

Enter Marks : 26

Enter Name of Student : Harry

Enter Marks : 70

Dictionary of Student Created :

{'Ram': 92, 'Akshat': 68, 'Abhishek': 54, 'Nitish': 44, 'John': 26, 'Harry': 70}

Ram - Distinction [92]

Akshat - First Class [68]

Abhishek - Second Class [54]

https://colab.research.google.com/drive/1CsiBVuHx9moFuQp6r8usQpnipnOVozBC#scrollTo=c37P-dr38ZR7&printMode=true 1/2
8/27/22, 11:02 PM DSE Lab Assignment 01.ipynb - Colaboratory
Nitish - Pass [44]

John - Fail [26]

Harry - Distinction [70]

Q 2. Write a Python Program to create a 1D array of numbers from 0 to 9

import numpy as np

array = np.array([i for i in range(10)]) #add i in the array till it satisfy the range condition

print(array)

[0 1 2 3 4 5 6 7 8 9]

# OR WE CAN ALSO USE THIS METHOD

import numpy as np

y=np.arange(0,10) # 10 will be excluded

print(y)

[0 1 2 3 4 5 6 7 8 9]

Q 3. Write a NumPy program to create a 3x4 matrix filled with values from 10 to 21.

import numpy as np

n=np.arange(10,22).reshape(3,4) # 22 will be excluded and 3 & 4 are no. of rows & columns respectively

print(n)

[[10 11 12 13]

[14 15 16 17]

[18 19 20 21]]

Colab paid products


-
Cancel contracts here

https://colab.research.google.com/drive/1CsiBVuHx9moFuQp6r8usQpnipnOVozBC#scrollTo=c37P-dr38ZR7&printMode=true 2/2

You might also like