0% found this document useful (0 votes)
2 views

quetions_python

The document contains a series of Python programming questions and answers, covering topics such as data types, list operations, functions, and error handling. It includes examples of variable assignments, list slicing, and the use of conditional statements. Additionally, it addresses common programming concepts like modules and environmental variables in Python.

Uploaded by

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

quetions_python

The document contains a series of Python programming questions and answers, covering topics such as data types, list operations, functions, and error handling. It includes examples of variable assignments, list slicing, and the use of conditional statements. Additionally, it addresses common programming concepts like modules and environmental variables in Python.

Uploaded by

8695862277
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

How can we find which data type ans:variable

2.a=10+5j

B=10-5j

A*b=? Ans:125+0j

3.long_1=”python script”

Long_2=’c’+long_1[1:]

Ans: cython script

4.long=”Django is python”

Print long[1:4]--------- jan

5.Read only list are?______

6.emp_data=(“rahul”,65,78,84)

Print emp_data[:3]

Ans: ('rahul', 65, 78)

7.emp_data=(“rahul”,65,78,84)

Print emp_data[-5:5]

Ans: ('rahul', 65, 78, 84)

8.val1=4

Result=val1**val2

Val2=2

Print result

Ans:Error in Programm invalid syntax

9.basket_1=[‘roses’,’lillies’,’sunflower’]

Basket_2=[‘lotus’,’lillies’,’red roses’]

Ans:set(basket_1+basket_2)

10.emp_data=[“rahul”,24,5.80,65,78,84]

Print emp_data[-1:5]

Ans[]

11.language=[‘shell’,’perl’,’python’]

L_type=”are scripting languages”

Language+L_type

Ans: TypeError: can only concatenate list (not "str") to list


12.Flower_basket={“roses”:10,”lilies”:8,”sunflower”:4}

How to get value of “lilies”

13.Flower_basket={“roses”:10,”lilies”:8,”sunflower”:4}*2 ??

14.which datatype doesnot support membership operator

a)list

b)tuple

c)string

d)int

15.x=y=10

If(x is y):

X=20

Else:

X=30

Print x

16.x=y=10

If (x is not y):

X=20

Elif (x>=y):

X=30

Y=20

Else:

X=40

Print x,y

17. import sys

Nargs=len(sys.argv)

Total=0

Cnt=0

While(cnt<nargs):

Total+= int(sys.argv)
Cnt+=1

18.def foobar():

Print”django”

Print’rails’

Foobar()

Print’pylons’

19.x=10

Def foobar(x):

Global x=20

X=30

Foobar(X)

Print x

20. def foobar(a=30,b=40)

Print a,b

X=10

Y=20

Foobar(X)

21.def foobar(a=30,b=40):

Print a,b

X=10

Y=20

Foobar()

22.def fib(n):

If n==0:

Return 1

Else:

Return (fib(n-1)+fib(n-2))

23.length=input(“enter the length : “)

Breadth=input(“enter the breadth : “)

Perimeter=(length+breadth)*2 ??

24.Environmental variable of python to find modules??

25.def foo():
Print”is half the battle”

Print” a good beginning”

If __name__==’__main__’

Foo()

Print ‘makes a good ending’

26.which statement is false regarding modules?

Ans: modules cannot have variables.

27. mod.py

def foo():

Print “iron python”

If __name__==’__main__

Foo()

Print”jython”

Appl:---

Import mod

Print ‘cython’

Mod.foo()

28.x=y=10

If(x is y):

X=20

Y=20

Else:

X=30

Y=40

Print x,y

You might also like