Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Given a sentence as input, find all the unique combinations of two words and print the word combinations that are not adjacent in the original sentence in lexicographical order.Input


The input will be a single line containing a sentence.Output


The output should be multiple lines, each line containing a valid unique combination of two words. The words in each line should be lexicographical order and the lines as well should be in lexicographical order. A valid combination will not contain the words that appear adjacent in the given sentence. Print "No Combinations" if there are no valid combinations.


Input1:

google.com


Output1:

{'g': 2, 'o': 3, 'l': 1, 'e': 1, 'c' : 1, 'm' : 1}


Input2:

Netflix.com


Output2:

{'N': 1, 'e':1, 't': 1, 'f':1, 'l': 1, 'i': 1, 'x':1, '.': 1, 'c': 1, 'o': 1, 'm':1}





Who discovered python?


write a program that contains two functions i.e., encrypt_string() and decrypt_string()a.encrypt_string(s): Thisfunction uses the following dictionary:encrypt={'a':'1','b':'@','c':'*','d':')','e':'$','f':'#'}This function should accept a string as its parameter and return anencrypted string. To encrypt a string, use the dictionary given above. Read each character of the string(match it with the keyin the dictionary)and replace each character with the given encrypted value(valuein the dictionary)and return the encrypted string.b.decrypt_string(s)This function uses the following dictionary:decrypt={'1':'a','@':'b','*':'c',')':'d','$':'e','#':'f'}This function should accept an encrypted string as its parameter and return the decrypted/original string. To decrypt a string, use the dictionary given above. Read each character of the string(match it with the key in the dictionary) andreplace each character with the given decrypted value(value in the dictionary)and return the decrypted string.


Add two polynomials

Given two polynomials A and B, write a program that adds the given two polynomials

Output:-

Print the addition of polynomials A and B.

The format for printing polynomials is: Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0,

If co-efficient is zero then don't print the term.

If the term with highest degree is negative, the term should be represented as -Cix^Pi.

For the term where power is 1 represent it as C1x instead of C1x^1.

If the degree of polynomial is zero and the constant term is also zero, then just print 0 to represent the polynomial.

For term Cix^Pi, if the coefficient of the term Ci is 1, simply print x^Pi instead of 1x^Pi.

Explanation

If M = 4 and polynomial A

For power 0, co-efficient is 5

For power 1, co-efficient is 0

For power 2, co-efficient is 10

For power 3, co-efficient is 6.

If N = 3 and for polynomial B

For power 0, co-efficient is 1

For power 1, co-efficient is 2

For power 2, co-efficient is 4.


How to explain this code?


def readAccounts(accounts,fileName):

  pathlibPath = pathlib.Path(fileName)

  if pathlibPath.exists():

    with open(fileName,'r+') as file:

      accountData = json.load(file)

      for account in accountData:

        accountFromFile=Account()

        accountFromFile.setAccountInformation(account['username'],account['password'],account['name'],account['suname'],account['birthDate'],account['listFriends'])

        accounts.append(accountFromFile)

         

        

     

   

main()


How to explain this code?


elif(choice=="3"):#Search for a user

      name =input("Enter the name of account: ")

      surname =input("Enter the surname of the account: ")

       

      accountExist=False

      for acc in accounts:

        if acc.getName()==name and acc.getSuname()==surname:

          acc.displayAccountInformation()

          print("")

          accountExist=True

      if accountExist==False:

        print("\nThe account does not exist.\n")


How to explain this code???


if(choice=="1"):#Sign up: register to the system

      newAccount=Account()

      newAccount.signUp()

      accounts.append(newAccount)

      saveAccounts(accounts,FILE_NAME)

    elif(choice=="2"):#Sign in

      username =input("Enter the username of the account: ")

      password =input("Enter the password of account: ")

       

      accountExist=False

      for acc in accounts:


def square_area(matrix,l_x,l_y,side_length):

  count=2

  for i in range(l_x,l_y+side_length):

    for j in range(l_y,l_y+side_length):

      if matrix[i][j]==1:

        count+=1

      else:

        return 0

  return count 

m,n=map(int,input().split())

markers={'X':1,'O':0}

matrix=[[markers[i] for i in input().split()] for _ in range(m)]

areas=[]

for l_x in range(m):

  for l_y in range(n):

    for side_length in range(1,min(n-l_y+1,m-l_x+1)):

      areas.append(square_area(matrix,l_x,l_y,side_length))

print(max(areas))

ouput:5

it should print output:4

for some test cases wrong?


How to explain this code?



import pathlib 

import json



class Account:

  #Constructor

  def __init__(self):

    self.username =""

    self.password =""

    self.name =""

    self.suname =""

    self.birthDate =""

    self.listFriends = [] #(characterised by the account username)

       

  #This function allows to create a new Account

  def signUp(self):

    self.username =input("Enter the username: ")

    self.password =input("Enter the password: ")

    


LATEST TUTORIALS
APPROVED BY CLIENTS