0% found this document useful (0 votes)
17 views1 page

Python and MySQL Programs for XI

The document outlines a series of Python programming tasks and MySQL commands for students in an Informatics Practices course. It includes exercises such as calculating sums, finding the largest number, generating factorials, and creating a student database. The tasks are designed to enhance programming skills and database management understanding.

Uploaded by

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

Python and MySQL Programs for XI

The document outlines a series of Python programming tasks and MySQL commands for students in an Informatics Practices course. It includes exercises such as calculating sums, finding the largest number, generating factorials, and creating a student database. The tasks are designed to enhance programming skills and database management understanding.

Uploaded by

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

AADHARSHILA VIDYAPEETH

CD BLOCK, PITAMPURA
INFORMATICS PRACTICES
PROGRAM FILE – XI

PYTHON PROGRAMS:
1. WAP to display the sum of numbers from 1 to 10 using for loop.
2. WAP to find the largest of three numbers using if-elif-else. Accept the numbers from
the user.
3. WAP to calculate the factorial of a number using while loop. Accept the number from
the user.
4. WAP to print the multiplication table of a number using for loop. Accept the number
from the user.
e.g., the pattern displayed must be 3X2=6
5. WAP to print the Fibonacci series up to n terms using a for loop.
6. WAP to check whether a person is eligible to vote or not.
7. WAP to check whether the entered year is a leap year or not.
8. WAP to print all prime numbers from 1 to 100.
9. Write a menu driven program for the following options of calculator:
a. Addition
b. Subtraction
c. Multiplication
d. Division
e. exponentiation
[Link] a menu-driven program
a. to check whether a number is even or odd using if-else.
b. to check whether a number is positive, negative or zero.
c. to count the number of vowels, present in the string.
d. To check there a number is palindrome or not.

MySQL Commands:
[Link] a table named 'students' with columns for student ID, name, class, age and
contact number where studentID is primary key and contact number is NOT NULL.
[Link] 10 records into the 'students' table
[Link] the class of a student in the 'students' table
[Link] a record from the 'students' table
[Link] all records from the 'students' table

Common questions

Powered by AI

A number is a palindrome if it reads the same forward and backward. Convert the number to a string, then compare the original to its reverse obtained through slicing (e.g., using [::-1]). This negates the need for loops or additional structures, leveraging Python’s efficient string handling capabilities .

Creating the 'students' table with a primary key guarantees unique student identification, preventing duplicate entries, while a NOT NULL constraint on contact numbers ensures essential contact data is always collected. These choices streamline database operations by enforcing data integrity and consistently preserving vital information .

To compute the factorial using a while loop, start with a result variable set to 1. Use the while loop to multiply this variable by the decrementing value from the input number down to 1. The while loop is preferred for its straightforward control over the decrementing process and its readability when the loop condition needs constant checking .

The program can use a for loop iterating through numbers 2 to 100. For each number, a nested loop checks divisibility only up to its square root since higher factors would have been previously checked. This reduces unnecessary calculations compared to checking up to the number itself, making the approach efficient .

The program can be expanded with a function that iterates through each character of the string, checking for vowels using a set of predefined vowel characters. A for loop is suitable for linear traversal, and a counter increment approach can efficiently tally occurrences, revealing insights into string composition .

Implementing a loop for multiplication tables promotes computational thinking by engaging students in a systematic approach to iterate over a sequence of multipliers, demonstrating loops' power in automating repetitive tasks accurately and efficiently. It fosters deeper understanding of iteration and mathematical operations .

The menu-driven program should prompt for operation choice, then receive two numeric inputs. For division, incorporate a conditional check to prevent division by zero, possibly through an if-else statement to inform users of invalid input. Using try-except statements can also robustly handle unexpected conditions .

A user-defined function to determine if a year is a leap year should first check if the year is divisible by 4. If true, the function should then verify that the year is not divisible by 100, unless it is also divisible by 400. This conditional logic checks ensure leap year rules are properly applied .

The program should verify if the input age is a number and then check if it meets the voting age threshold, typically 18. Ensuring data validation prevents erroneous data from being processed, reinforcing program reliability and correctness. Validating inputs guarantees accurate decision-making outcomes .

Procedural programming techniques facilitate problem-solving by structuring programs into clear, sequential tasks. When finding the largest of three numbers, using if-elif-else structures aligns with procedural logic, breaking the problem into understandable and reusable steps, promoting clarity and logical flow .

You might also like