Skip to content

Instantly share code, notes, and snippets.

View rajkushwaha0521's full-sized avatar

Raj Kushwaha rajkushwaha0521

View GitHub Profile
@rajkushwaha0521
rajkushwaha0521 / Billing_system.py
Last active August 10, 2019 18:35
Vendors billing system on rules
# PF-Assgn-39
# This verification is based on string match.
'''A vendor at a food court is in the process of automating his order management system.
The vendor serves the following menu – Veg Roll, Noodles, Fried Rice and Soup and also maintains the quantity available for each
item. The customer can order any combination of items. The customer is provided the item if the requested quantity of item is
available with the vendor.
Write a python program which implements the following functions.
place_order(*item_tuple): This function accepts the order placed by the customer. Consider it to be a variable length argument
as each customer may have a different order.
@rajkushwaha0521
rajkushwaha0521 / double.py
Created August 10, 2019 11:54
Write a python function, check_double(number) which accepts a whole number and returns True if it satisfies the given conditions. The number and its double should have exactly the same number of digits. Both the numbers should have the same digits ,but in different order. Otherwise it should return False. Example: If the number is 125874 and its…
#PF-Assgn-38
def check_double(number):
num1=str(number*2)
number=str(number)
count=0
for x in number:
if x in num1:
count+=1
else:
@rajkushwaha0521
rajkushwaha0521 / largest.py
Created August 10, 2019 09:49
Write a python function, create_largest_number(), which accepts a list of numbers and returns the largest number possible by concatenating the list of numbers. Note: Assume that all the numbers are two digit numbers. Also write the pytest test cases to test the program.
#PF-Assgn-36
#Sample Input Expected Output
#23,34,55 553423
def create_largest_number(number_list):
num=""
number_list=sorted(number_list)
for x in range(-1,-len(number_list)-1,-1):
num+=str(number_list[x])
return int(num)
@rajkushwaha0521
rajkushwaha0521 / solution.py
Created August 10, 2019 09:39
A teacher is in the process of generating few reports based on the marks scored by the students of her class in a project based assessment. Assume that the marks of her 10 students are available in a tuple. The marks are out of 25. Write a python program to implement the following functions:
#PF-Assgn-35
#find_more_than_average(): Find and return the percentage of students who have scored more than the average mark of the class.
#generate_frequency(): Find how many students have scored the same marks. For example, how many have scored 0, how many have scored 1, how many have scored 3….how many have scored 25. The result should be populated in a list and returned.
#sort_marks(): Sort the marks in the increasing order from 0 to 25. The sorted values should be populated in a list and returned.#
#Sample Input Expected Output
#list_of_marks = (12,18,25,24,2,5,18,20,20,21) 70.0
# [0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 2, 1, 0, 0, 1, 1]
# [2, 5, 12, 18, 18, 20, 20, 21, 24, 25]
@rajkushwaha0521
rajkushwaha0521 / pair.py
Created August 9, 2019 19:34
Write a python function, find_pairs_of_numbers() which accepts a list of positive integers with no repetitions and returns count of pairs of numbers in the list that adds up to n. The function should return 0, if no such pairs are found in the list. Also write the pytest test cases to test the program.
#PF-Assgn-34
#Sample Input Expected Output
#[1, 2, 7, 4, 5, 6, 0, 3], 6 3
#[3, 4, 1, 8, 5, 9, 0, 6], 9 4
Estimated Time: 30 minutes
def find_pairs_of_numbers(num_list,n):
count=0
for x in num_list:
index=num_list.index(x)+1
@rajkushwaha0521
rajkushwaha0521 / mergelist.py
Created August 9, 2019 18:59
Write a python program which merges the content of two given lists and sorts the merged list.
#PF-Exer-29
def merge_lists(list1,list2):
for x in range(len(list2)):
list1.append(list2[x])
new_merge_list=list1
return new_merge_list
def sort_list(merged_list):
merged_list=sorted(merged_list)
return merged_list
@rajkushwaha0521
rajkushwaha0521 / common_characters.py
Last active November 8, 2021 06:47
Write a python program to display all the common characters between two strings. Return -1 if there are no matching characters. Note: Ignore blank spaces if there are any. Perform case sensitive string comparison wherever necessary.
#PF-Assgn-33
#Sample Input Expected output
#"I like Python"
#"Java is a very popular language" lieyon
#==========================================================================================================================
def find_common_characters(msg1,msg2):
list=[]
for x in msg1:
@rajkushwaha0521
rajkushwaha0521 / infytq.py
Last active November 27, 2024 16:50
Care hospital wants to know the medical speciality visited by the maximum number of patients. Assume that the patient id of the patient along with the medical speciality visited by the patient is stored in a list. The details of the medical specialities are stored in a dictionary as follows: { "P":"Pediatrics", "O":"Orthopedics", "E":"ENT } Writ…
#PF-Assgn-32
#{"P":"Pediatrics","O":"Orthopedics","E":"ENT}
#Sample Input Expected Output
#[101,P,102,O,302,P,305,P] Pediatrics
#[101,O,102,O,302,P,305,E,401,O,656,O] Orthopedics
#[101,O,102,E,302,P,305,P,401,E,656,O,987,E] ENT
#================================================================================================================
def max_visited_speciality(patient_medical_speciality_list,medical_speciality):
@rajkushwaha0521
rajkushwaha0521 / string_palindrome.py
Created August 9, 2019 08:38
Write a function, check_palindrome() to check whether the given string is a palindrome or not. The function should return true if it is a palindrome else it should return false. Note: Initialize the string with various values and test your program. Assume that all the letters in the given string are all of the same case. Example: MAN, civic, WOW…
#PF-Assgn-31
def check_palindrome(word):
x=word[::-1]
if x== word:
return True
else:
return False
status=check_palindrome("malayalam")
if(status):
@rajkushwaha0521
rajkushwaha0521 / string_counter.py
Last active May 8, 2022 14:35
Given a string containing uppercase characters (A-Z), compress the string using Run Length encoding. Repetition of character has to be replaced by storing the length of that run. Write a python function which performs the run length encoding for a given String and returns the run length encoded String. Provide different String values and test yo…
#PF-Assgn-30
#Sample Input Expected Output
#AAAABBBBCCCCCCCC 4A4B8C
#AABCCA 2A1B2C1A
#====================================================================================================================
def encode(message):
output=''
privious=message[0]