CBSE COMPUTER SCIENCE
رفتن به کانال در Telegram
QUESTION BANK, REFERENCE BOOK, LAB MANUAL , WORKSHEET ETC., PYTHON TEXT BOOK AND REFERENCE BOOKS, 01. ASK QUESTIONS AT https://t.me/joinchat/FJ1noGs-64I0OWI1
نمایش بیشتر549
مشترکین
اطلاعاتی وجود ندارد24 ساعت
اطلاعاتی وجود ندارد7 روز
اطلاعاتی وجود ندارد30 روز
آرشیو پست ها
======================== RESTART: /home/maha/argtypes.py =======================
Default Arguments :
Sum = 60
Sum = 85
Sum = 100
Positional Arguments :
Sum = 120
Sum = 61
Sum = 53
Sum = 36
Sum = 36
Key-Word Arguments
Sum = 600
Sum = 600
Sum = 600
>>>
'''type of arguments
1. Default arguments
2. Positional arguments
3. Keyword Arguments
4. Variable- length Arguments'''
#1. Default Arguments
def sum(a=10,b=20,c=30): # Formal Arguments : a,b,c
s=a+b+c
print("Sum = ",s)
print("Default Arguments :")
sum() # No Arguments
sum(35)
sum(45,25)
#Positional Arguments
print("Positional Arguments :")
sum(20,40,60) #Values
x=11
y=12
z=13
sum(x)
sum(x,y)
sum(x,y,z)
sum(y,z,x)
#Key-Word Arguments
print("Key-Word Arguments")
a=100
b=200
c=300
sum(a,b,c)
sum(b,a,c)
sum(b,c,a)
>>> str="Python Programming"
>>> x=str[3:15]
>>> print(x,len(x))
hon Programm 12
>>>
>>> l=[2.4,"Python",'S',"Java",7,32,4,[6,7,8],[2,3,4],3,'q']
>>> print(l[1:len(l)-2:2])
['Python', 'Java', 32, [6, 7, 8]]
>>>
import random as r
val=35
P=7
Num=0
for i in range(1,5):
x=r.randint(0,P-1)
Num=val+x
print(x," " ,Num,"$")
P=P-1
c=10
def add():
#global c
c+=2
print("Inside value=",c)
add()
c=15
print("in Main=",c)
c=10
def add():
global c
c+=2
print("Inside value=",c)
add()
c=15
print("in Main=",c)
CBSE COMPUTER SCIENCE : 21-22, [26.04.21 21:58]
def si(p,r,t):
return p*r*t/100
print(si(100,5,2))
CBSE COMPUTER SCIENCE : 21-22, [26.04.21 21:58]
output : 10.0
=========================== RESTART: /home/maha/t.py ===========================
Enter number of terms : 5
Sum of Natural number is 15
Enter number of terms : 5
Sum of Natural number is 15
Enter number of terms : 5
Sum of Natural number is 15
Enter number of terms : 5
Sum of Natural number is 15
>>>
#Sum of the Natural Numbers S=1+2+3+...+N
def funct():
N=int(input("Enter number of terms : "))
S=0
for i in range(1,N+1,1):
S=S+i
print("Sum of Natural number is ",S)
funct()
def funct(M):
S=0
for i in range(1,M+1,1):
S=S+i
print("Sum of Natural number is ",S)
N=int(input("Enter number of terms : "))
funct(N)
def funct():
N=int(input("Enter number of terms : "))
S=0
for i in range(1,N+1,1):
S=S+i
return S
d=funct()
print("Sum of Natural number is ",d)
def funct(M):
S=0
for i in range(1,N+1,1):
S=S+i
return S
N=int(input("Enter number of terms : "))
d=funct(N)
print("Sum of Natural number is ",d)
================== RESTART: E:\Program Files\Python37-32\T.py ==================
Case 1: Sum= 30
Case 2: Sum= 30
Case 3: Sum= 30
Case 4: Sum= 30
>>>
#No Argument No Return
def sum():
x=10
y=20
print("Case 1: Sum=",x+y)
sum()
#Argument No Return
def sum(x,y):
print("Case 2: Sum=",x+y)
a=10
b=20
sum(a,b)
#No Argument , Return
def sum():
x=10
y=20
return x+y
c=sum()
print("Case 3: Sum=",c)
#Argument , Return
def sum(x,y):
return x+y
a=10
b=20
c=sum(a,b)
print("Case 4: Sum=",c)
Q1. Find error in the following code(if any) and correct code by rewriting code and
underline the correction;‐
x= int(“Enter value of x:”)
for in range [0,10]:
if x=y
print( x + y)
else:
print( x‐y)
Q2. Rewrite the following program after finding and correcting syntactical errors and
underlining it.
a, b = 0
if (a = b)
a +b = c
print( z)
Q3. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
250 = Number
WHILE Number<=1000:
if Number=>750
print (Number)
Number=Number+100
else
print( Number*2)
Number=Number+50
Q4. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
Val = int(rawinput("Value:"))
Adder = 0
for C in range(1,Val,3)
Adder+=C
if C%2=0:
Print (C*10)
Else:
print (C*)
print (Adder)
Q5. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
25=Val
for I in the range(0,Val)
if I%2==0:
print( I+1)
Else:
print (I‐1
Q6. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
STRING=""WELCOME
NOTE""
for S in range[0,8]:
print (STRING(S))
Q7. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
a=int{input("ENTER FIRST NUMBER")}
b=int(input("ENTER SECOND NUMBER"))
c=int(input("ENTER THIRD NUMBER"))
if a>b and a>c
print("A IS GREATER")
if b>a and b>c:
Print(" B IS GREATER")
if c>a and c>b:
print(C IS GREATER)
Q8. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
i==1
a=int(input("ENTER FIRST NUMBER"))
FOR i in range[1, 11];
print(a,"*=", i ,"=",a * i)
Q9. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
a=”1”
while a>=10:
print("Value of a=",a)
a=+1
Q10. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
Num=int(rawinput("Number:"))
sum=0
for i in range(10,Num,3)
Sum+=1
if i%2=0:
print(i*2)
Else:
print(i*3 print Sum)
Q11. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
weather='raining'
if weather='sunny':
print("wear sunblock")
elif weather='snow':
print("going skiing")
else:
print(weather)
