பைத்தான் - List பயன்படுத்தப்பட்ட நிரல்கள் | 12th Computer Science : Chapter 9 : Python Modularity and OOPS : Lists, Tuples, Sets And Dictionary
List பயன்படுத்தப்பட்ட நிரல்கள்
நிரல் 1:1 முதல் 20 வரையான எண்களில் 4-ல் வகுபடும் எண்களை பெறும் List ஒன்றை உருவாக்கும் நிரல் ஒன்றை எழுதுக.
divBy4=[ ]
for i in range(21):
if (i%4==0) :
divBy4.append(i)
print(divBy4)
வெளியீடு
[0, 4, 8, 12, 16, 20]
நிரல்2 : BRICS ன் உறுப்பு நாடுகளின் List-ஐ வரையறை செய்து, உள்ளீடு செய்யப்படும் நாடு BRICS ன் உறுப்பா (அல்லது) இல்லையா என்பதை பரிசோதிக்கும் நிரலை எழுதுக.
country=["India", "Russia", "Srilanka", "China", "Brazil"]
is_member = input("Enter the name of the country:")
if is_member in country:
print(is_member, " is the member of BRICS")
else:
print(is_member, " is not a member of BRICS")
வெளியீடு
Enter the name of the country:
India India is the member of BRICS
வெளியீடு
Enter the name of the country:
Japan Japan is not a member of BRICS
நிரல் 3: ஆறு பாடங்களின் மதிப்பெண்களை உள்ளீடாகப் பெற்று, ஒவ்வொரு பாடத்திலும் பெற்ற மதிப்பெண்களை அச்சிட்டு மதிப்பெண்களின் கூட்டுத்தொகையை காண்பிக்கும் பைத்தான் நிரலை எழுதுக.
marks=[]
subjects=['Tamil', 'English', 'Physics', 'Chemistry', 'Comp. Science', 'Maths']
for i in range(6):
m=int(input("Enter Mark = "))
marks.append(m)
for j in range(len(marks)):
print("{ }, { } Mark = { } ".format(j1+,subjects[j],marks[j]))
print("Total Marks = ", sum(marks))
வெளியீடு
Enter Mark = 45
Enter Mark = 98
Enter Mark = 76
Enter Mark = 28
Enter Mark = 46
Enter Mark = 15
1. Tamil Mark = 45
2. English Mark = 98
3. Physics Mark = 76
4. Chemistry Mark = 28
5. Comp. Science Mark = 46
6. Maths Mark = 15
Total Marks = 308
நிரல் 4: 5 பொருள்களின் விலையை List-ல் பெற்று, அனைத்து விலைகளின் கூட்டுத்தொகை, பெருக்கற்தொகை மற்றும் சராசரியைக் கண்டறியும் பைத்தான் நிரலை எழுதுக.
items=[]
prod=1
for i in range(5):
print ("Enter price for item {}: ".format(i+1))
p=int(input())
items.append(p)
for j in range(len(items)):
print("Price for item { } = Rs. { }".format(j+1,items[j]))
prod = prod* items[j]
print("Sum of all prices = Rs.'', sum(items))
print("Product of all prices = Rs.'', prod)
print("Average of all prices = Rs.",sum(items)/len(items))
வெளியீடு
Enter price for item 1:
5
Enter price for item 2:
10
Enter price for item 3 :
15
Enter price for item 4:
20
Enter price for item 5:
25
Price for item 1 = Rs. 5
Price for item 2 = Rs. 10
Price for item 3 = Rs. 15
Price for item 4 = Rs. 20
Price for item 5 = Rs. 25
Sum of all prices = Rs. 75
Product of all prices = Rs. 375000
Average of all prices = Rs. 15.0
நிரல்5: ஆண்டுக்கு 1 இலட்சத்திற்கு மேல் ஊதியம் பெறும் பணியாளர்களின் எண்ணிக்கையை கணக்கிடும் பைத்தான் நிரல் n எண்ணிக்கையிலான பணியாளர்களின் மாத ஊதியத்தை உள்ளீடாக பெற வேண்டும்.
count=0
n=int(input("Enter no. of employees: "))
print("No. of Employees",n)
salary=[]
for i in range(n):
print("Enter Monthly Salary of Employee { } Rs.: ".format(i+1))
s=int(input())
salary.append(s)
for j in range(len(salary)):
annual_salary = salary[j] * 12
print ("Annual Salary of Employee { } is:Rs. {}".format(j+1,annual_salary))
if annual_salary >= 100000:
count = count + 1
print("{ } Employees out of { } employees are earning more than Rs. 1 Lakh per annum". format(count, n))
வெளியீடு
Enter no. of employees: 5
No. of Employees 5
Enter Monthly Salary of Employee 1 Rs.:
3000
Enter Monthly Salary of Employee 2 Rs.:
9500
Enter Monthly Salary of Employee 3 Rs.:
12500
Enter Monthly Salary of Employee 4 Rs.:
5750
Enter Monthly Salary of Employee 5 Rs.:
8000
Annual Salary of Employee 1 is:Rs. 36000
Annual Salary of Employee 2 is:Rs. 114000
Annual Salary of Employee 3 is:Rs. 150000
Annual Salary of Employee 4 is:Rs. 69000
Annual Salary of Employee 5 is:Rs. 96000
2 Employees out of 5 employees are earning more than Rs. 1 Lakh per annum
நிரல் 6: 1 முதல் 10 வரையுள்ள தொடர் எண்களை ஏற்கும் List ஒன்றை உருவாக்குவதற்கான நிரலை எழுதுக. பிறகு அனைத்து இரட்டைப்படை எண்களையும் நீக்கவிட்டு இறுதிப்பட்டியலை அச்சிடுக
Num = []
for xin range(1,11):
Num.append(x)
print("The List of numbers from 1 to 10 = "', Num)
for index, i in enumerate(Num):
if(i%2==0):
del Num[index]
print("The List after deleting even numbers = ", Num)
வெளியீடு
The List of numbers from 1 to 10 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
The List after deleting even numbers = [1, 3, 5, 7, 9]
நிரல் 7: பைபோனாசி வரிசையை உருவாக்கி அதை List -ல் சேமிப்பதற்கான நிரலை எழுதுக. பிறகு அனைத்து மதிப்புகளின் கூட்டுத்தொகையைக் கண்டறிக.
a=-1
b=1
n=int(input("Enter no. of terms: "))
i=0
sum=0
Fibo=[ ]
while i<n:
S = a + b
Fibo.append(s)
sum+=s
a = b
b = S
i+=1
print("Fibonacci series upto "+ str(n) +" terms is : " + str(Fibo))
print("The sum of Fibonacci series: ",sum)
வெளியீடு
Enter no. of terms: 10
Fibonacci series upto 10 terms is : [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
The sum of Fibonacci series: 88