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

Compute The Greatest Common Divisor and Least Common Multiple of Two Integers

The document contains code snippets to perform various operations on lists and files in Python. These include functions to: 1) Calculate greatest common divisor and least common multiple of two integers; 2) Display Fibonacci series up to a given limit; 3) Perform linear and binary search on a list; 4) Sort lists using bubble, selection, and insertion sort algorithms; 5) Read and analyze contents of text files by counting characters, words, and occurrences of specific strings.
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)
63 views

Compute The Greatest Common Divisor and Least Common Multiple of Two Integers

The document contains code snippets to perform various operations on lists and files in Python. These include functions to: 1) Calculate greatest common divisor and least common multiple of two integers; 2) Display Fibonacci series up to a given limit; 3) Perform linear and binary search on a list; 4) Sort lists using bubble, selection, and insertion sort algorithms; 5) Read and analyze contents of text files by counting characters, words, and occurrences of specific strings.
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
You are on page 1/ 26

1. Compute the greatest common divisor and least common multiple of two integers.

def calculate_gcd(a, b):

while b:

a, b = b, a % b

return a

def calculate_lcm(a, b):

return (a * b) // calculate_gcd(a, b)

# Input integers

num1 = 36

num2 = 48

# Calculate GCD and LCM

gcd_result = calculate_gcd(num1, num2)

lcm_result = calculate_lcm(num1, num2)

2.Display the terms of a Fibonacci series

def fibonacci_series(limit):

a, b = 0, 1

print("Fibonacci series up to", limit, ":")

print(a, end=" ")

while b <= limit:

print(b, end=" ")

a, b = b, a + b

# Set the limit for the series

series_limit = 100 # Change this limit as needed

# Display the Fibonacci series

fibonacci_series(series_limit)
1. Write a menu driven program to enter a number and perform following using
functions :
a. Check if it is a perfect number.
b. Check if it is palindrome
c. Armstrong number
d. Print sum of its digit
e. Print its factorial

def is_perfect_number(num):

sum_divisors = 0

for i in range(1, num):

if num % i == 0:

sum_divisors += i

return sum_divisors == num

# Function to check if a number is a palindrome

def is_palindrome(num):

return str(num) == str(num)[::-1]

# Function to check if a number is an Armstrong number

def is_armstrong_number(num):

order = len(str(num))

temp = num

sum_armstrong = 0

while temp > 0:

digit = temp % 10

sum_armstrong += digit ** order

temp //= 10

return sum_armstrong == num

# Function to calculate the sum of digits

def sum_of_digits(num):

return sum(int(digit) for digit in str(num))


# Function to calculate factorial

def factorial(num):

if num == 0 or num == 1:

return 1

else:

return num * factorial(num - 1)

# Menu function

def menu():

print("Menu:")

print("a. Check if a number is a perfect number")

print("b. Check if a number is a palindrome")

print("c. Check if a number is an Armstrong number")

print("d. Print sum of its digit")

print("e. Print its factorial")

print("f. Exit")

# Main program

while True:

menu()

choice = input("Enter your choice (a/b/c/d/e/f): ")

if choice == 'a':

number = int(input("Enter a number to check for perfectness: "))

if is_perfect_number(number):

print(number, "is a perfect number.")

else:

print(number, "is not a perfect number.")

elif choice == 'b':

number = int(input("Enter a number to check for palindrome: "))


if is_palindrome(number):

print(number, "is a palindrome.")

else:

print(number, "is not a palindrome.")

elif choice == 'c':

number = int(input("Enter a number to check for Armstrong number: "))

if is_armstrong_number(number):

print(number, "is an Armstrong number.")

else:

print(number, "is not an Armstrong number.")

elif choice == 'd':

number = int(input("Enter a number to find the sum of its digits: "))

print("The sum of digits of", number, "is:", sum_of_digits(number))

elif choice == 'e':

number = int(input("Enter a number to find its factorial: "))

print("The factorial of", number, "is:", factorial(number))

elif choice == 'f':

print("Exiting the program. Goodbye!")

break

else:

print("Invalid choice. Please enter a valid option.")

1. WAP to implement a function L_Search that take input as a list and implement
searching using linear Search.

# Function to perform linear search

def linear_search(arr, key):

found = False

position = -1 # Initialize position to -1, indicating not found

# Iterate through the list

for i in range(len(arr)):

if arr[i] == key: # If element found


found = True

position = i + 1 # Set position to index + 1 (1-based indexing)

break

return found, position

# Input list

input_list = [12, 34, 56, 78, 90]

# Element to search in the list

search_element = 56

# Perform linear search

is_found, element_position = linear_search(input_list, search_element)

# Display result

if is_found:

print(f"Element {search_element} found at position {element_position}.")

else:

print(f"Element {search_element} not found in the list.")

5. WAP to implement a function B_Search that take input as a list and implement searching
using Binary Search.

def binary_search(arr, target):

low = 0

high = len(arr) - 1

while low <= high:

mid = (low + high) // 2

if arr[mid] == target:

return mid

elif arr[mid] < target:


low = mid + 1

else:

high = mid - 1

return -1 # Target not found

# Example usage:

my_list = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

target_element = 12

result = binary_search(my_list, target_element)

if result != -1:

print(f"Element found at index {result}")

else:

print("Element not found in the list")

6. WAP to sort a list of numbers using Bubble sort.

def bubble_sort(arr):

n = len(arr)

# Traverse through all array elements

for i in range(n):

# Last i elements are already in place, so no need to check them again

for j in range(0, n-i-1):

# Traverse the array from 0 to n-i-1. Swap if the element found is greater

# than the next element

if arr[j] > arr[j+1]:

arr[j], arr[j+1] = arr[j+1], arr[j]

# Example usage:

my_list = [64, 34, 25, 12, 22, 11, 90]

print("Original list:", my_list)


bubble_sort(my_list)

print("Sorted list:", my_list)

7.WAP to sort a list of numbers using Selection sort. def selection_sort(arr):

n = len(arr)

# Traverse through all array elements

for i in range(n):

# Find the minimum element in the remaining unsorted array

min_index = i

for j in range(i+1, n):

if arr[j] < arr[min_index]:

min_index = j

# Swap the found minimum element with the first element

arr[i], arr[min_index] = arr[min_index], arr[i]

# Example usage:

my_list = [64, 25, 12, 22, 11]

print("Original list:", my_list)

selection_sort(my_list)

print("Sorted list:", my_list)

8.WAP to sort a list of numbers using Insertion sort.

def insertion_sort(arr):

# Traverse through 1 to len(arr)

for i in range(1, len(arr)):

key = arr[i]
# Move elements of arr[0..i-1], that are greater than key, to one position ahead

j=i-1

while j >= 0 and key < arr[j]:

arr[j + 1] = arr[j]

j -= 1

arr[j + 1] = key

# Example usage:

my_list = [12, 11, 13, 5, 6]

print("Original list:", my_list)

insertion_sort(my_list)

9.Create a dictionary with the roll number, name and marks of n students in a class and display the
names of students who have scored marks above 75.print("Sorted list:", my_list)

# Create a dictionary with roll number, name, and marks of students

students = {

101: {'name': 'Alice', 'marks': 80},

102: {'name': 'Bob', 'marks': 70},

103: {'name': 'Charlie', 'marks': 85},

104: {'name': 'David', 'marks': 60},

# Add more students as needed

1.Read a text file and display the number of vowels/consonants/uppercase/lowercase characters in


the file

# Function to count vowels, consonants, uppercase, and lowercase characters in a text file

def count_chars(filename):

vowels = 'aeiouAEIOU'

consonants = 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ'

with open(filename, 'r') as file:

text = file.read()

vowel_count = sum(1 for char in text if char in vowels)


consonant_count = sum(1 for char in text if char in consonants)

uppercase_count = sum(1 for char in text if char.isupper())

lowercase_count = sum(1 for char in text if char.islower())

return vowel_count, consonant_count, uppercase_count, lowercase_count

# Example usage

file_path = 'sample.txt' # Replace 'sample.txt' with the path to your text file

vowels, consonants, uppercase, lowercase = count_chars(file_path)

print(f"Number of vowels: {vowels}")

print(f"Number of consonants: {consonants}")

print(f"Number of uppercase characters: {uppercase}")

print(f"Number of lowercase characters: {lowercase}")

2.Read a text file line by line and display each word separated by a #. # Function to read a text file
line by line and display words separated by #

def display_words(file_name):

with open(file_name, 'r') as file:

for line in file:

words = line.split()

formatted_line = ' # '.join(words)

print(formatted_line)

# Example usage

file_path = 'sample.txt' # Replace 'sample.txt' with the path to your text file

display_words(file_path)

3.Read a text file and count total number of occurrence of word ‘To’ and ‘TO’

# Function to count occurrences of 'To' and 'TO' in a text file

def count_to_occurrences(file_name):
count_to = 0

with open(file_name, 'r') as file:

text = file.read()

# Split the text into words and count occurrences of 'To' and 'TO'

words = text.split()

count_to += words.count('To')

count_to += words.count('TO')

return count_to

# Example usage

file_path = 'sample.txt' # Replace 'sample.txt' with the path to your text file

total_to_count = count_to_occurrences(file_path)

print(f"Total occurrences of 'To' and 'TO': {total_to_count}")

4.Read a text file and count total number of words starting with ‘M’# Function to count words
starting with 'M' in a text file

def count_words_starting_with_m(file_name):

count_m_words = 0

with open(file_name, 'r') as file:

text = file.read()

# Split the text into words and count words starting with 'M'

words = text.split()

count_m_words += sum(1 for word in words if word.startswith('M') or word.startswith('m'))

return count_m_words

# Example usage

file_path = 'sample.txt' # Replace 'sample.txt' with the path to your text file

total_m_words_count = count_words_starting_with_m(file_path)
print(f"Total words starting with 'M': {total_m_words_count}")

5. Write a program to open a file “Student.txt” in write mode. Store names of the five students
along with the marks in English, Maths and Computer Science in this fill

# Student data to be written to the file

students_data = [

{'name': 'Alice', 'english': 85, 'maths': 90, 'computer_science': 78},

{'name': 'Bob', 'english': 78, 'maths': 92, 'computer_science': 80},

{'name': 'Charlie', 'english': 90, 'maths': 85, 'computer_science': 88},

{'name': 'David', 'english': 82, 'maths': 88, 'computer_science': 76},

{'name': 'Eva', 'english': 88, 'maths': 80, 'computer_science': 92},

# Writing student data to the file "Student.txt"

file_name = 'Student.txt'

with open(file_name, 'w') as file:

for student in students_data:

file.write(f"Name: {student['name']}, English: {student['english']}, Maths: {student['maths']}, "

f"Computer Science: {student['computer_science']}\n"

6.Write a program in Python to create a text file ‘Note.txt’ to write few lines into it. If you don’t want
more lines then enter 0(zero) to quit.m

# Function to count words starting with 'M' in a text file

def count_words_starting_with_m(file_name):

count_m_words = 0

with open(file_name, 'r') as file:

text = file.read()

# Split the text into words and count words starting with 'M'

words = text.split()

count_m_words += sum(1 for word in words if word.startswith('M') or word.startswith('m'))


return count_m_words

# Example usage

file_path = 'sample.txt' # Replace 'sample.txt' with the path to your text file

total_m_words_count = count_words_starting_with_m(file_path)

print(f"Total words starting with 'M': {total_m_words_count}")

7.Write a program that reads characters from the keyboard one by one. All lower case characters get
stored inside the file LOWER, all upper case characters get stored inside the file UPPER and all other
characters get stored inside file OTHERS`

# Function to categorize characters into files

def categorize_characters():

with open('LOWER.txt', 'w') as


lower_file, open('UPPER.txt', 'w') as
upper_file, open('OTHERS.txt', 'w') as
others_file:
while True:

char = input("Enter a character (Press 'Q' to quit): ")

if char == 'Q' or char == 'q':

break

if char.islower():

lower_file.write(char + '\n')

elif char.isupper():

upper_file.write(char + '\n')

else:

others_file.write(char + '\n')
# Call the function to categorize characters

categorize_characters()

8. Write a function display to open the same file ‘Student.txt’ in read mode which will retrieve
and display all the records available in the file “Student.txt

# Function to display records from the file

def display(file_name):

try:

with open(file_name, 'r') as file:

records = file.readlines()

for record in records:

print(record.strip()) # Remove newline character for better formatting

except FileNotFoundError:

print("File not found!")

# Example usage

file_path = 'Student.txt' # Replace with the path to your 'Student.txt' file

display(file_path

9. Write a program that copies a text file “source.txt” onto “target.txt” barring the lines starting
with “@” sign.

# Function to copy contents from source to target excluding lines starting with '@'

def copy_file(source_file, target_file):

try:

with open(source_file, 'r') as source, open(target_file, 'w') as target:

for line in source:

if not line.startswith('@'):

target.write(line)

print(f"Contents copied from {source_file} to {target_file} excluding lines starting with '@'")

except FileNotFoundError:

print("File not found!")


# Example usage

source_file_path = 'source.txt' # Replace with the path to your source file

target_file_path = 'target.txt' # Replace with the path to your target filecopy

10. Remove all the lines that contain the character 'a' in a file and write it to another file.

# Function to remove lines containing 'a' and write to another file

def remove_lines_with_a(input_file, output_file):

try:

with open(input_file, 'r') as file_in, open(output_file, 'w') as file_out:

for line in file_in:

if 'a' not in line.lower(): # Case insensitive check for 'a'

file_out.write(line)

print(f"Lines containing 'a' removed and written to {output_file}")

except FileNotFoundError:

print("File not found!")

# Example usage

input_file_path = 'input.txt' # Replace with the path to your input file

output_file_path = 'output.txt' # Replace with the path to your output file

remove_lines_with_a(input_file_path, output_file_path)

11. Write a function Line() in Python to use the previous text ile (Notebook.txt) in appropriate
mode to retrieve all the lines. Count the number of lines available in the file and display all the with
line number.

# Function to retrieve all lines from the file and display with line numbers

def Line(file_name):

try:

with open(file_name, 'r') as file:

lines = file.readlines()

line_count = len(lines)

print(f"Total number of lines in '{file_name}': {line_count}\n")


for idx, line in enumerate(lines, start=1):

print(f"Line {idx}: {line.strip()}")

except FileNotFoundError:

print("File not found!")

# Example usage

file_path = 'Notebook.txt' # Replace with the path to your 'Notebook.txt' file

Line(file_path)

12. A file contains a list of telephone numbers in the following form:

Arvind 7258031

Sachin 7259197

The names contain only one word the names and telephone numbers are separated by white spaces

Write program to read a file and display its contents in two columns.

# Function to display file contents in two columns

def display_two_columns(file_name):

try:

with open(file_name, 'r') as file:

for line in file:

name, number = line.split()

print(f"{name.ljust(15)}{number}")

except FileNotFoundError:

print("File not found!")

# Example usage

file_path = 'telephone_numbers.txt' # Replace with the path to your file

display_two_columns(file_path)

BINARY FILE:

1.Each record of passenger stores following information

#[Passenger_number, Name, Amount]

Write a menu driven program to implement :


write() : to add record in a file

Display() : to read and print all records.

Countrec() : to read contents of file “passenger.dat” and display the details of those passengers
where amount is above 5000.

#Also display number of passengers with amount above 5000.

import struct

# Function to add a record to the file

def write_record(file_name):

try:

with open(file_name, 'ab') as file:

passenger_number = int(input("Enter Passenger Number: "))

name = input("Enter Name: ")

amount = float(input("Enter Amount: "))

# Pack data into bytes and write to file

record = struct.pack('i 10s f', passenger_number, name.encode(), amount)

file.write(record)

print("Record added successfully.")

except FileNotFoundError:

print("File not found!")

# Function to display all records from the file

def display_records(file_name):

try:

with open(file_name, 'rb') as file:

record_size = struct.calcsize('i 10s f')

while True:

record = file.read(record_size)

if not record:

break
passenger_number, name, amount = struct.unpack('i 10s f', record)

print(f"Passenger Number: {passenger_number}, Name: {name.decode().strip()}, Amount:


{amount}")

except FileNotFoundError:

print("File not found!")

# Function to count records with amount above 5000

def count_records_above_5000(file_name):

count = 0

try:

with open(file_name, 'rb') as file:

record_size = struct.calcsize('i 10s f')

while True:

record = file.read(record_size)

if not record:

break

_, _, amount = struct.unpack('i 10s f', record)

if amount > 5000:

count += 1

print(f"Passenger with amount above 5000: {amount}")

print(f"Total passengers with amount above 5000: {count}")

except FileNotFoundError:

print("File not found!")

# Menu-driven program

def menu():

file_name = 'passenger.dat'

while True:

print("\nMenu:")

print("1. Add Record")

print("2. Display All Records")


print("3. Count Records with Amount Above 5000")

print("4. Exit")

choice = input("Enter your choice: ")

if choice == '1':

write_record(file_name)

elif choice == '2':

display_records(file_name)

elif choice == '3':

count_records_above_5000(file_name)

elif choice == '4':

break

else:

print("Invalid choice. Please enter a valid option.")

# Run the program

menu()

2.Create a binary file with roll number, name and marks. Input a roll number and update the marks.

import struct

# Function to create a binary file with roll number, name, and marks

def create_file(file_name):

try:

with open(file_name, 'wb') as file:

records = [

(101, 'Alice', 85),

(102, 'Bob', 70),

(103, 'Charlie', 92),

# Add more records as needed (roll number, name, marks)

for record in records:


file.write(struct.pack('10s i f', record[1].encode(), record[0], record[2]))

print(f"File '{file_name}' created with initial records.")

except FileNotFoundError:

print("File not found!")

# Function to update marks for a specific roll number

def update_marks(file_name, roll_number, new_marks):

try:

with open(file_name, 'r+b') as file:

record_size = struct.calcsize('10s i f')

while True:

record = file.read(record_size)

if not record:

break

name, roll, marks = struct.unpack('10s i f', record)

if roll == roll_number:

file.seek(-struct.calcsize('i f'), 1)

file.write(struct.pack('i f', roll, new_marks))

print(f"Marks updated for Roll Number {roll_number} to {new_marks}")

break

else:

print(f"Roll Number {roll_number} not found in the file.")

except FileNotFoundError:

print("File not found!")

# Create the file with initial records

file_path = 'student_data.bin'

create_file(file_path)

# Example usage: Update marks for Roll Number 102 to 75

roll_number_to_update = 102
new_marks_value = 75

update_marks(file_path, roll_number_to_update, new_marks_value)

14. Create a CSV file user.csv .Entering user-id and password, read and search the password for given
user id.

A CSV file contains data Empno, Employee Name, Salary. Write a program to implement functions:

write() : to write records into a file

read() : to read records from the file

count1() : to count total number of employees getting salary more than 10000

count2() : to display names of students who get salary between 5000 to 9000

avg_sal() : to find average sal

import struct

# Function to create a binary file with roll number, name, and marks

def create_file(file_name):

try:

with open(file_name, 'wb') as file:

records = [

(101, 'Alice', 85),

(102, 'Bob', 70),

(103, 'Charlie', 92),

# Add more records as needed (roll number, name, marks)

for record in records:

file.write(struct.pack('10s i f', record[1].encode(), record[0], record[2]))

print(f"File '{file_name}' created with initial records.")

except FileNotFoundError:

print("File not found!")

# Function to update marks for a specific roll number


def update_marks(file_name, roll_number, new_marks):

try:

with open(file_name, 'r+b') as file:

record_size = struct.calcsize('10s i f')

while True:

record = file.read(record_size)

if not record:

break

name, roll, marks = struct.unpack('10s i f', record)

if roll == roll_number:

file.seek(-struct.calcsize('i f'), 1)

file.write(struct.pack('i f', roll, new_marks))

print(f"Marks updated for Roll Number {roll_number} to {new_marks}")

break

else:

print(f"Roll Number {roll_number} not found in the file.")

except FileNotFoundError:

print("File not found!")

# Create the file with initial records

file_path = 'student_data.bin'

create_file(file_path)

# Example usage: Update marks for Roll Number 102 to 75

roll_number_to_update = 102

new_marks_value = 75

update_marks(file_path, roll_number_to_update, new_marks_value)

STACK

Q.1 Each node of a stack contains the following information:

i) Item No.
ii) Name

Write a menu driven program to implement Push (), Pop () and Display () .

import csv

# Function to write records to a CSV file

def write_records(file_name):

with open(file_name, 'w', newline='') as file:

writer = csv.writer(file)

writer.writerow(["Empno", "Employee Name", "Salary"])

records = [

(101, 'Alice', 12000),

(102, 'Bob', 8000),

(103, 'Charlie', 11000),

(104, 'David', 5000),

# Add more records as needed (Empno, Employee Name, Salary)

writer.writerows(records)

print(f"Records written to '{file_name}' successfully.")

# Function to read records from a CSV file

def read_records(file_name):

with open(file_name, 'r') as file:

reader = csv.DictReader(file)

for row in reader:

print(row)

# Function to count employees with salary more than 10000

def count_employees_above_10000(file_name):

count = 0

with open(file_name, 'r') as file:


reader = csv.DictReader(file)

for row in reader:

if int(row['Salary']) > 10000:

count += 1

print(f"Total employees getting salary more than 10000: {count}")

# Function to display names of employees with salary between 5000 to 9000

def display_names_salary_between_5000_and_9000(file_name):

with open(file_name, 'r') as file:

reader = csv.DictReader(file)

for row in reader:

salary = int(row['Salary'])

if 5000 <= salary <= 9000:

print(f"Employee Name: {row['Employee Name']}")

# Function to find average salary

def average_salary(file_name):

total_salary = 0

count = 0

with open(file_name, 'r') as file:

reader = csv.DictReader(file)

for row in reader:

total_salary += int(row['Salary'])

count += 1

avg = total_salary / count if count > 0 else 0

print(f"Average salary: {avg}")

# Example usage

file_path = 'employee_data.csv'

# Writing records to the file


write_records(file_path)

# Reading records from the file

read_records(file_path)

# Counting employees with salary more than 10000

count_employees_above_10000(file_path)

# Displaying names of employees with salary between 5000 to 9000

display_names_salary_between_5000_and_9000(file_path)

# Calculating average salary

average_salary(file_path)

Q.16 Perform following queries :

• Create database session2023

• Create table table CUSTOMER with following data and frame queries for the following:

• apply appropriate (Primary key)

Table Name: CUSTOMER_DETAILS

CUST_ID CUT_NAME ACCT_TYPE ACCULT_AMT DOJ GENDER

CNR_101 Manoj Saving 1025000 1999-02-19 M

CNR_102 Rahul Current 1326000 1998-01-11 M

CNR_103 John Saving 1425000 1999-02-04 M

CNR_104 Steve Salary Saving 1825000 1998-02-21 M

CNR_105 Manpreet Current 1125000 1998-05-12 F

CNR_106 Catherine Saving 1026000 1999-01-13 F

CNR_107 RameshSaving 2025000 1998-04-22 M

a. To list the names of customer with their date of joining in descending order.

b. To display female customers with accumulated amount greater than 1025000.


c. To list the customers having 15 letters name.

d. Select CUST_ID,ACCT_TYPE,DOJ from CUSTOMER_DETAILS where GENDER=’F’.

e. Describe CUSTOMER

Connections:

CREATE DATABASE IF NOT EXISTS session2023;

USE session2023;

CREATE TABLE IF NOT EXISTS CUSTOMER_DETAILS (

CUST_ID VARCHAR(10) PRIMARY KEY,

CUST_NAME VARCHAR(50),

ACCT_TYPE VARCHAR(20),

ACCUMULATED_AMT INT,

DOJ DATE,

GENDER CHAR(1)

);

INSERT INTO CUSTOMER_DETAILS (CUST_ID, CUST_NAME, ACCT_TYPE, ACCUMULATED_AMT, DOJ,


GENDER) VALUES

('CNR_101', 'Manoj', 'Saving', 1025000, '1999-02-19', 'M'),

('CNR_102', 'Rahul', 'Current', 1326000, '1998-01-11', 'M'),

('CNR_103', 'John', 'Saving', 1425000, '1999-02-04', 'M'),

('CNR_104', 'Steve', 'Salary Saving', 1825000, '1998-02-21', 'M'),

('CNR_105', 'Manpreet', 'Current', 1125000, '1998-05-12', 'F'),

('CNR_106', 'Catherine', 'Saving', 1026000, '1999-01-13', 'F'),

('CNR_107', 'Ramesh', 'Saving', 2025000, '1998-04-22', 'M');

a.SELECT CUST_NAME, DOJ

FROM CUSTOMER_DETAILS
ORDER BY DOJ DESC;.

b. SELECT *

FROM CUSTOMER_DETAILS

WHERE GENDER = 'F' AND ACCUMULATED_AMT > 1025000;

c. SELECT *

FROM CUSTOMER_DETAILS

WHERE LENGTH(CUST_NAME) = 15;

D. DESCRIBE CUSTOMER_DETAILS;

You might also like