├── Binary String.txt
├── FizzBuzz.py
├── PASSWORD_GENERATOR.txt
├── README.md
├── ROCK _PAPER _SCISSOR.txt
├── SIMPLE_CALCULATOR.txt
├── STOPWATCH.txt
├── armstr.txt
├── assigment.py
├── assignmet16.py
├── customer_bill.py
├── dfact.py
├── discount.py
├── fact.py
├── fib.py
├── formating strings.py
├── itertools.combinations.txt
├── kmeans.ipynb
├── list.py
├── parameterized cnstrtctr.py
├── pascal triangle.txt
├── password.py
├── product price.py
├── rev.py
├── reversestr.py
├── reversing vowels in str.txt
├── rvrs_vwl_str.py
├── triangle.py
└── uprlwr.py
/Binary String.txt:
--------------------------------------------------------------------------------
1 | n=4
2 | #s=1111
3 | s="01101"
4 | c=0
5 | for i in s:
6 | if i=='1':
7 | print(i)
8 | c+=1
9 | print("count",c)
10 | print((c*(c-1))//2)
11 | ----------------------------->
12 | def binarySubstring(self,n,s):
13 | #code here
14 | count=0 #1111
15 | for i in s:
16 | if i=='1':
17 | count+=1
18 | return (count*(count-1))//2
--------------------------------------------------------------------------------
/FizzBuzz.py:
--------------------------------------------------------------------------------
1 | """Given an integer n, return a string array answer (1-indexed) where:
2 |
3 | answer[i] == "FizzBuzz" if i is divisible by 3 and 5.
4 | answer[i] == "Fizz" if i is divisible by 3.
5 | answer[i] == "Buzz" if i is divisible by 5.
6 | answer[i] == i (as a string) if none of the above conditions are true.
7 | Example 1:
8 | Input: n = 3
9 | Output: ["1","2","Fizz"]
10 | Example 2:
11 | Input: n = 5
12 | Output: ["1","2","Fizz","4","Buzz"]"""
13 | class Solution:
14 | def fizzBuzz(self, n: int) -> List[str]:
15 | r=[]
16 | for i in range(1,n+1):
17 | if(i%3==0 and i%5==0):
18 | r.append("FizzBuzz")
19 | elif(i%3==0):
20 | r.append( "Fizz")
21 | elif(i%5==0):
22 | r.append("Buzz")
23 | else:
24 | r.append(str(i))
25 | return r
26 |
--------------------------------------------------------------------------------
/PASSWORD_GENERATOR.txt:
--------------------------------------------------------------------------------
1 | import random
2 | import string
3 | password=""
4 | print("Welcome to Password Generator..")
5 | n_letters=int(input("How many letters you want in your password:\n"))
6 | n_digits=int(input("How many digits you want in your password:\n"))
7 | n_char=int(input("How many special characters you want in your password:\n"))
8 | if((n_letters<=0)or(n_digits<=0)or(n_char<=0)):
9 | print("invalid input")
10 | else:
11 | pas=""
12 | letters=[random.choice(string.ascii_letters)for i in range(n_letters)]
13 | symbol=[random.choice(string.punctuation)for i in range(n_char)]
14 | numbers=[random.choice(string.digits)for i in range(n_digits)]
15 | password=letters+symbol+numbers
16 | print(password)
17 | random.shuffle(password)
18 | print(password)
19 | pas="".join(password)
20 | print(f"the generated password is:{pas}")
21 | # for i in password:
22 | # pas+=i
23 | #print(pas)"""
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
Hi 👋 , I'm Sandhya
3 | I'm interested in Artificial intelligence and DataScience
4 |
5 |
6 |
7 | - 🚶♀️ I’m currently learning **Artificial intelligence**
8 |
9 | - 🙄 I’m looking to collaborate on projects **related to Artificial intelligence**
10 |
11 | - 🎆 How to reach me **madhunagulasandhya5@gmail.com**
12 |
13 | Connect with me:
14 |
15 |
16 |
17 |
18 |
19 | Languages and Tools:
20 |
21 |
22 | 
23 |
24 | 
25 |
26 | 
27 |
--------------------------------------------------------------------------------
/ROCK _PAPER _SCISSOR.txt:
--------------------------------------------------------------------------------
1 | import random
2 | print("Winning rules of the game ROCK PAPER SCISSOR as follows:\n ROCK vs SCISSCOR->ROCK Wins\n SCISSCOR vs PAPER->SCISSCOR Wins\n PAPER vs ROCK->PAPER Wins")
3 | user_choice=int(input("enter your choice:\n0.Rock\n1.Paper\n2.Scissor\n"))
4 | if user_choice<0 or user_choice>2:
5 | print("enter a valid number to play the game")
6 | else:
7 | print(f"user entered {user_choice}to play the game")
8 | computer_choice=random.randint(0,2)
9 | print(f"computer entered {computer_choice} to play the game")
10 | if(user_choice==computer_choice):
11 | print("It\'s a draw case.so,play again")
12 | elif(user_choice==0 and computer_choice==2):
13 | print("You won the game")
14 | elif(user_choice==2 and computer_choice==0):
15 | print("You lost the game")
16 | elif(user_choice>computer_choice):
17 | print("You won the game")
18 | elif(user_choice>computer_choice):
19 | print("You won the game")
20 | else:
21 | print("You lost the game")
22 | print("I hope you enjoyed with this game...\n ..Thank you..")
23 |
--------------------------------------------------------------------------------
/SIMPLE_CALCULATOR.txt:
--------------------------------------------------------------------------------
1 | print("Designing a Simple Calculator")
2 | def addition(num1,num2):
3 | return num1+num2
4 | def subtract(num1,num2):
5 | return num1-num2
6 | def multiplication(num1,num2):
7 | return num1*num2
8 | def division(num1,num2):
9 | return num1/num2
10 | print("operators to calculate to perfrom an operation:\n"
11 | "1.ADD\n"
12 | "2.SUBSTRACTION\n"
13 | "3.MULTIPLICATION\n"
14 | "4.DIVISION\n")
15 | #"5.EXIT\n")
16 | operator=int(input("select an operator:"))
17 | a=int(input("enter first number:"))
18 | b=int(input("enter second number:"))
19 | if operator==1:
20 | print(a, "+",b,"=",
21 | addition(a,b))
22 | elif(operator==2):
23 | print(a, "-",b,"=",
24 | subtract(a,b))
25 | elif(operator==3):
26 | print(a, "*",b,"=",
27 | multiplication(a,b))
28 | elif(operator==4):
29 | print(a, "/",b,"=",
30 | division(a,b))
31 | #elif(operator==5):
32 | #break
33 | # print("exit")
34 | else:
35 |
36 | print("invalid")
37 |
--------------------------------------------------------------------------------
/STOPWATCH.txt:
--------------------------------------------------------------------------------
1 | import time
2 | Time=int(input("Enter the time in Seconds:"))
3 | for i in range(Time,0,-1):
4 | sec=i%60
5 | min=int(i/60)%60
6 | hour=int(i/3600)
7 | print(f"{hour:02}:{min:02}:{sec:02}")
8 | time.sleep(1)
9 | print("TIME UP...")
--------------------------------------------------------------------------------
/armstr.txt:
--------------------------------------------------------------------------------
1 | n=int(input("enter a number:"))
2 |
3 | temp=n
4 |
5 | sum=0
6 |
7 | while(temp>0):
8 |
9 | r=n%10
10 |
11 | sum=sum+(r*r*r)
12 |
13 | n=n//10
14 | if(temp==sum):
15 |
16 | print(temp,"is a armstrong number")
17 |
18 | else:
19 |
20 | print(temp,"is not an armstrong number")
21 |
--------------------------------------------------------------------------------
/assigment.py:
--------------------------------------------------------------------------------
1 | #lex_auth_012693711503400960120
2 | #Write a python program to find and display the product of three positive integer values based on the rule mentioned below:
3 |
4 | #It should display the product of the three values except when one of the integer value is 7.
5 | #In that case, 7 should not be included in the product and the values to its left also should not be included.
6 | #If there is only one value to be considered, display that value itself.
7 | #If no values can be included in the product, display -1.
8 |
9 |
10 |
11 |
12 | def find_product(num1,num2,num3):
13 | product=0
14 | if(num3==7):
15 | product=-1
16 | elif( num2==7 ):
17 | product=num3
18 | elif(num1==7 ):
19 | product=num2*num3
20 | else:
21 | product=num1*num2*num3
22 | #write your logic here
23 | return product
24 |
25 | #Provide different values for num1, num2, num3 and test your program
26 | product=find_product(7,6,2)
27 | print(product)
28 |
--------------------------------------------------------------------------------
/assignmet16.py:
--------------------------------------------------------------------------------
1 | #lex_auth_012693780491968512136
2 | #You have x no. of 5 rupee coins and y no. of 1 rupee coins.
3 | #You want to purchase an item for amount z.
4 | #The shopkeeper wants you to provide exact change.
5 | #You want to pay using minimum number of coins. How many 5 rupee coins and 1 rupee coins will you use? If exact change is not possible then display -1.
6 |
7 |
8 | def make_amount(rupees_to_make,no_of_five,no_of_one):
9 | five_needed=0
10 | one_needed=0
11 | #Start writing your code here
12 | #Populate the variables: five_needed and one_needed
13 | if(rupees_to_make )>5*no_of_five+1*no_of_one:
14 | print(-1)
15 | else:
16 | five_needed=rupees_to_make//5
17 | one_needed=rupees_to_make -(5*five_needed)
18 | print("No. of Five needed :", five_needed)
19 | print("No. of One needed :", one_needed)
20 | # Use the below given print statements to display the output
21 | # Also, do not modify them for verification to work
22 | # print("No. of Five needed :", five_needed)
23 | #print("No. of One needed :", one_needed)
24 | #print(-1)
25 | #Provide different values for rupees_to_make,no_of_five,no_of_one and test your program
26 | make_amount(28,8,5)
27 |
--------------------------------------------------------------------------------
/customer_bill.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SandhyaMadhunagula/Python/b08c40a47f4d4af2d2b68d43cb6cb394652c5130/customer_bill.py
--------------------------------------------------------------------------------
/dfact.py:
--------------------------------------------------------------------------------
1 | def fact(i):
2 | if i==1:
3 | return 1
4 | else:
5 | return((i*fact(ni-1))
6 | n=int(input("enter number"))
7 | print("the fact of num is",n, "==",fact(n))
8 |
--------------------------------------------------------------------------------
/discount.py:
--------------------------------------------------------------------------------
1 | """1.if the mobile brand is Apple then the discount is 10% else the discount is 5%
2 | 2.all shoes have 2% tax and no discount"""
3 | #-------------------------->
4 | def purchase_product(product_type, price, mobile_brand = None):
5 | if product_type == "Mobile":
6 | if mobile_brand == "Apple":
7 | discount = 10
8 | else:
9 | discount = 5
10 | total_price = price - price * discount / 100
11 | else:
12 | total_price = price + price * 2 / 100
13 |
14 | print("Total price of " +product_type+ " is "+str(total_price))
15 |
16 | purchase_product("Mobile", 20000, "Apple")
17 | purchase_product("Shoe", 300)
18 |
19 |
--------------------------------------------------------------------------------
/fact.py:
--------------------------------------------------------------------------------
1 | n=int(input("enter"))
2 | fact=1
3 | while(n>0):
4 | fact=fact*n
5 | n-=1
6 | print("factorial of nuber is" ,fact)
7 |
8 |
9 |
--------------------------------------------------------------------------------
/fib.py:
--------------------------------------------------------------------------------
1 | def fib(n):
2 | if n<=1:
3 | return 1
4 | else:
5 | return (fib(n-1)+fib(n-2))
6 | nterms=int(input("range"))
7 | print("fibn series")
8 | for i in range (nterms):
9 | print(fib(i))
10 |
--------------------------------------------------------------------------------
/formating strings.py:
--------------------------------------------------------------------------------
1 | #Use " " (a space) to insert a space before positive numbers and a minus sign before negative numbers:
2 | txt = "The temperature is between {: } and {: } degrees celsius."
3 | print(txt.format(-3, 7))
4 | #Use "," to add a comma as a thousand separator:
5 | txt = "The universe is {:,} years old."
6 | print(txt.format(13800000000))
7 | #Use "+" to always indicate if the number is positive or negative:
8 | txt = "The temperature is between {:+} and {:+} degrees celsius."
9 | print(txt.format(-3, 7))
10 | #To demonstrate, we insert the number 8 to set the available space for the value to 8 characters.
11 | #Use "^" to center-align the value:
12 | txt = "We have {:^8} chickens."
13 | print(txt.format(49))
14 | #To demonstrate, we insert the number 8 to set the available space for the value to 8 characters.
15 | #Use ">" to right-align the value:
16 | txt = "We have {:>8} chickens."
17 | print(txt.format(49))
18 | #To demonstrate, we insert the number 8 to set the available space for the value to 8 characters.
19 | #Use "<" to left-align the value:
20 | txt = "We have {:<8} chickens."
21 | print(txt.format(49))
22 | #Use "b" to convert the number into binary format:
23 | txt = "The binary version of {0} is {0:b}"
24 | print(txt.format(5))
25 | #Use "%" to convert the number into a percentage format:
26 | txt = "You scored {:%}"
27 | print(txt.format(0.25))
28 | #Or, without any decimals:
29 | txt = "You scored {:.0%}"
30 | print(txt.format(0.25))
31 | #Use "o" to convert the number into octal format:
32 | txt = "The octal version of {0} is {0:o}"
33 | print(txt.format(10))
34 | #Use "x" to convert the number into Hex format:
35 | txt = "The Hexadecimal version of {0} is {0:x}"
36 | print(txt.format(255))
37 | #Use "F" to convert a number into a fixed point number, but display inf and nan as INF and NAN:
38 | x = float('inf')
39 | txt = "The price is {:F} dollars."
40 | print(txt.format(x))
41 | #same example, but with a lower case f:
42 | txt = "The price is {:f} dollars."
43 | print(txt.format(x))
44 | #Use "f" to convert a number into a fixed point number, default with 6 decimals, but use a period followed by a number to specify the number of decimals:
45 | txt = "The price is {:.2f} dollars."
46 | print(txt.format(45))
47 | #without the ".2" inside the placeholder, this number will be displayed like this:
48 | txt = "The price is {:f} dollars."
49 | print(txt.format(45))
50 | #Use "_" to add a underscore character as a thousand separator:
51 | txt = "The universe is {:_} years old."
52 | print(txt.format(13800000000))
53 | #To demonstrate, we insert the number 8 to specify the available space for the value.
54 | #Use "=" to place the plus/minus sign at the left most positiontxt = "The temperature is {:=8} degrees celsius."
55 | print(txt.format(-5))
56 |
--------------------------------------------------------------------------------
/itertools.combinations.txt:
--------------------------------------------------------------------------------
1 | from itertools import combinations
2 | a,n=input().split()
3 | a=sorted(a)
4 | n=int(n)
5 | for j in range(1,n+1):
6 | for i in list(combinations(a,j)):
7 | print(''.join(i))
--------------------------------------------------------------------------------
/list.py:
--------------------------------------------------------------------------------
1 | #lex_auth_012693750719488000124
2 | """Given a list of integer values.
3 | Write a python program to check whether it contains same number in adjacent position.
4 | Display the count of such adjacent occurrences"""
5 | def get_count(num_list):
6 | count=0
7 |
8 | # Write your logic here
9 | for i in range(0,len(num_list)-1):
10 | if(num_list[i]==num_list[i+1]):
11 | count+=1
12 | else:
13 | continue
14 |
15 | return count
16 |
17 | #provide different values in list and test your program
18 | num_list=[1,1,5,100,-20,-20,6,0,0]
19 | print(get_count(num_list))
20 |
--------------------------------------------------------------------------------
/parameterized cnstrtctr.py:
--------------------------------------------------------------------------------
1 | #If a constructor takes parameters then it would be called as parameterized constructor.
2 |
3 | class Mobile:
4 | def __init__(self, brand, price):
5 | print("Inside constructor")
6 | self.brand = brand
7 | self.price = price
8 |
9 | mob1=Mobile("Apple", 20000)
10 | print("Mobile 1 has brand", mob1.brand, "and price", mob1.price)
11 |
12 | mob2=Mobile("Samsung",3000)
13 | print("Mobile 2 has brand", mob2.brand, "and price", mob2.price)
14 |
--------------------------------------------------------------------------------
/pascal triangle.txt:
--------------------------------------------------------------------------------
1 | class Solution:
2 | def generate(self, numRows: int) -> List[List[int]]:
3 | lst=[]
4 | for i in range(numRows):
5 | lst.append([])
6 | for j in range(i+1):
7 | if j==0 or j==i:
8 | lst[i].append(1)
9 | else:
10 | lst[i].append(lst[i-1][j-1]+lst[i-1][j])
11 | return lst
12 |
13 |
--------------------------------------------------------------------------------
/password.py:
--------------------------------------------------------------------------------
1 | import string
2 | import random
3 |
4 | def generate_password(length):
5 | # Define the characters that can be used in the password
6 | characters = string.ascii_letters + string.digits + string.punctuation
7 | # Generate a random password
8 | password = ''.join(random.choice(characters) for i in range(length))
9 | return password
10 |
11 | # Prompt the user to specify the desired length of the password
12 | try:
13 | password_length = int(input("Enter the desired length of the password: "))
14 | # Ensure the length is a positive number
15 | if password_length <= 0:
16 | raise ValueError("The length must be a positive number.")
17 | except ValueError as e:
18 | print("Invalid input:", e)
19 | else:
20 | # Generate and display the password
21 | print("Generated password:", generate_password(password_length))
22 |
--------------------------------------------------------------------------------
/product price.py:
--------------------------------------------------------------------------------
1 | def purchase_product(product_type, price):
2 | discount = 10
3 | total_price = price - price * discount / 100
4 | print("Total price of " +product_type+ " is "+str(total_price))
5 |
6 | purchase_product("Mobile", 20000)
7 | purchase_product("Shoe", 200)
8 |
--------------------------------------------------------------------------------
/rev.py:
--------------------------------------------------------------------------------
1 | rev=0
2 | a=12345
3 | while(a>0):
4 | rem=int(a%10)
5 | rev=rev*10+rem
6 | a=int(a/10)
7 | print(rev)
8 |
--------------------------------------------------------------------------------
/reversestr.py:
--------------------------------------------------------------------------------
1 | """Write a function, check_palindrome() to check whether the given
2 | string is a palindrome or not. The function should return true if it is a
3 | palindrome else it should return false.
4 | Note: Initialize the string with various values and test your program.
5 | Assume that all the letters in the given string are all of the same case.
6 | Example: MAN, civic, WOW etc.
7 |
8 | #lex_auth_012693819159732224162
9 |
10 | def check_palindrome(word):
11 | x=word[::-1]
12 | if x==word:
13 | return True
14 | else:
15 | return False
16 | #Remove pass and write your logic here
17 |
18 | status=check_palindrome("malayalam")
19 | if(status):
20 | print("word is palindrome")
21 | else:
22 | print("word is not palindrome")
23 |
--------------------------------------------------------------------------------
/reversing vowels in str.txt:
--------------------------------------------------------------------------------
1 | a="practice"
2 | v='aeiou'
3 | x=""
4 | y=0
5 | z=""
6 | for i in a:
7 | if v.count(i):
8 | x=str(i)+x
9 | print(x)
10 | else:
11 | continue
12 | for i in a:
13 | if v.count(i):
14 | print(i)
15 | print("z:",z)
16 | z+=x[y]
17 | print(z)
18 | y+=1
19 | else:
20 | z+=i
21 | print(z)
22 |
23 | ---------------------------------->
24 | class Solution:
25 | def modify(self, s):
26 | # code here
27 | v='aeiou'
28 | x=""
29 | y=0
30 | z=""
31 | for i in s:
32 | if v.count(i):
33 | x=str(i)+x
34 | else:
35 | continue
36 | for i in s:
37 | if v.count(i):
38 | z+=x[y]
39 | y+=1
40 | else:
41 | z+=i
42 | return z
43 | sol=Solution()
44 | res=sol.modify("practice")
45 | print(res)
--------------------------------------------------------------------------------
/rvrs_vwl_str.py:
--------------------------------------------------------------------------------
1 | """REVERSE VOWELS OF A STRING:
2 | Given a string s, reverse only all the vowels in the string and return it.
3 | The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper cases, more than once.
4 | Example 1:
5 | Input: s = "hello"
6 | Output: "holle"
7 | Example 2:
8 | Input: s = "leetcode"
9 | Output: "leotcede" """
10 | class Solution:
11 | def reverseVowels(self, s: str) -> str:
12 | l=list(s)
13 | i=0
14 | j=len(l)-1
15 | v=['a','e','i','o','u','A','E','I','O','U']
16 | while(inum3) and (num2+num3>num1) and (num3+num1>num2):
12 | return success
13 | else:
14 | return failure
15 |
16 | #Use the following messages to return the result wherever necessary
17 |
18 |
19 | #Provide different values for the variables, num1, num2, num3 and test your program
20 | num1=3
21 | num2=3
22 | num3=5
23 | form_triangle(num1, num2, num3)
24 |
--------------------------------------------------------------------------------
/uprlwr.py:
--------------------------------------------------------------------------------
1 | s="SaNdHya"
2 | t=""
3 | for i in s:
4 | if i.isupper():
5 | t=i.lower()
6 |
7 | else:
8 | t=i.upper()
9 |
10 | print(t,end="")
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------