0% found this document useful (0 votes)
8 views3 pages

Python Lab Answers

The document contains a series of Python programming lab questions and corresponding code snippets, covering various topics such as operators, string manipulation, file handling, data structures, and mathematical operations. Each question is labeled from Q1 to Q11, with specific tasks like summing dictionary values, checking substrings, and performing array operations. The document serves as a comprehensive guide for practicing Python programming concepts.

Uploaded by

ravisai2505
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Python Lab Answers

The document contains a series of Python programming lab questions and corresponding code snippets, covering various topics such as operators, string manipulation, file handling, data structures, and mathematical operations. Each question is labeled from Q1 to Q11, with specific tasks like summing dictionary values, checking substrings, and performing array operations. The document serves as a comprehensive guide for practicing Python programming concepts.

Uploaded by

ravisai2505
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PYTHON PROGRAMMING LAB – ALL QUESTION ANSWERS (Q1–Q11)

Q1.A Operators demonstration

CODE:

a = 10

b=3

print(a+b, a-b, a*b, a/b)

Q1.B Sum dictionary values

CODE:

data={"a":10,"b":20,"c":30}

print(sum([Link]()))

Q2.A Length of string

CODE:

s="Hello"

c=0

for i in s: c+=1

Q2.B File count

CODE:

with open("[Link]") as f:

lines=[Link]()

Q2.C Substring check

CODE:

"Python" in "Welcome to Python"

Q3.A Array operations

CODE:

import array

a=[Link]('i',[10,20,30])

Q3.B List functions

CODE:

lst=[5,3,8,1]
Q3.C Add dict pair

CODE:

d={"name":"Sam"}

d["city"]="KKD"

Q4.A Array again

Q4.B Permutations

CODE:

import itertools

Q4.C Reverse file

CODE:

with open("[Link]") as f: ...

Q5.A Sort words

CODE:

with open("[Link]") as f: ...

Q5.B Scatter plot

CODE:

[Link](...)

Q6.A Inclusion–Exclusion

CODE:

A={1,2,3}

Q6.B JSON complex

CODE:

[Link](...)

Q6.C Even odd prime sum

CODE:

def prime(n): ...

Q7.A String length

Q7.B Tuple concatenation


Q7.C NumPy array

Q8.A Shape classes

Q8.B Default args

Q8.C Count vowels

Q9.A Set operations

Q9.B Sympy consistency

Q10.A Complex numbers

Q10.B List ops

Q10.C Graphs

Q11.A NumPy attrs

Q11.B Histogram

Q11.C Bayes theorem

You might also like