Question
Write a python program using function to print the sum of first n natural numbers. 

Answer

Get the step-by-step solution for this question inside the Vidyadip app.

Get the answer in the app

Need a full question paper?

Generate a complete, print-ready paper with questions like this in minutes — across 16+ boards, with answer keys.

Start Generating Free

Similar questions

Write a function to read the content from the file “India.txt”, and store the frequency of each character in dictionary and display the dictionary in the screen. Content of the file is: ‘‘India is the fastest growing economy. India is looking for more investments around the globe. The whole world is looking at India as a great market. Most of the Indians can foresee the heights that India is capable of reaching.’’ Output is: {'I': 5, 'n': 15, 'd': 7, 'i': 15, 'a': 17, ' ': 39, 's': 13, 't': 15, 'h': 10, 'e': 20, 'f': 5, 'g': 8, 'r': 9, 'o': 17, 'w': 3, 'c': 4, 'm': 4, 'y': 1, '.': 4, 'n': 4, 'l': 6, 'k': 3, 'v': 1, 'u': 1, 'b': 2, 'T': 1, 'M': 1, 'p': 1}
WAP to generate n lines of the following pattern on the computer screen:
WAF to take a list and inserting element as parameter and insert the new element at begining of the list.
Write SQL commands for the following:

Table: TEACHER

TID NAME AGE DEPT DATEOFJOIN SAL SEX
T118 Navin 40 Computer 2010-01-10 12000 M
T107 Chetna 37 History 2008-03-24 20000 F
T105 Sandeep 46 Maths 2006-12-12 30000 M
T110 Sangeeta 35 History 2010-07-01 25000 F
T101 Rudransh 42 Maths 2004-09-05 40000 M
T121 Neeraj 38 Physics 2011-04-01 28000 M

(i) To show information about the teachers of the history department.

(ii) To list the names of teachers earning a salary between 20000 and 30000.

(iii) To count the number of male teachers.

(iv) Display gender wise total number of teachers.

(v) To list the name and age of teachers of female teachers in descending order of date of join.

(vi) Increase the salary by 10% for Maths departments.

( vii) To delete the record of teacher Neeraj.

Write a menu driven python program using function Push(), Pop() and Display() to implement the stack. The program will store the name of the books.
Write a function update () to update the record in the binary file “student”, which consist of student number, student name and marks. The updation should be done on the basis of student number entered by the user.

Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables.


Table: VEHICLE

Code VTYPE PERKM
101 VOLVO BUS 160
102 AC DELUXE BUS 150
103 ORDINARY BUS 90
105 SUV 40
104 CAR 20

Note:

•PERKM is Freight Charges per kilometer

•VTYPE is Vehicle Type

NO NAME TDATE KM CODE NOP
101 Janish Kin 2015-11-13 200 101 32
103 Vedika sahai 2016-04-21 100 103 45
105 Tarun Ram 2016-03-23 350 102 42
102 John Fen 2016-02-13 90 102 40
107 AhmedKhan 2015-01-10 75 104 2
104 Raveena 2015-05-28 80 105 4
106 Kripal Anya 2016-02-06 200 101 25

Note:

•NO is Traveller Number

•KM is Kilometer travelled

•NOP is number of travellers travelled in vehicle

•TDATE is Travel Date

(i) To display NO, NAME, TDATE from the table TRAVEL in descending order of NO.

(ii) To display the NAME of all the travellers from the table TRAVEL who are travelling by vehicle with code 101 or 102.

(iii) To display the NO and NAME of those travellers from the table TRAVEL who travelled between ‘2015-12-31 ’and ‘2015-04-01 ’.

(iv) To display all the details from table TRAVEL for the travellers, who have travelled distance more than 100 KM in ascending order of NOP.

(v) SELECT COUNT (*), CODE FROM TRAVEL GROUP BY CODE HAVING COUNT(*)>1;

(vi) SELECT DISTINCT CODE FROM TRAVEL;

(vii) SELECT A.CODE,NAME,VTYPE FROM TRAVEL A,VEHICLE B WHERE A.CODE=B. CODE AND KM <90;

(viii) SELECT NAME,KM*PERKM FROM TRAVEL A, VEHICLE B WHERE A.CODE=B.CODE AND A.CODE=‘105 ’;

Write a menu driven program to do the following option on binary file “Student”. The program should implement through list which contains student number, student name and marks. Student Menu ------------------ 1) Add New Student 2) Display student details 3) Search student 4) Update a Record 5) Delete a Record 6) Save & Quit
Write algorithm for insert operation in Queue.
Write the function Insertion() to sort the list using Insertion sort technique. The function will take the list as parameter.