This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| QUESTION | |
| A robot moves in a plane starting from the original point (0,0). The robot can move UP, DOWN, LEFT, and RIGHT with given steps. Please write a program to compute the distance from the current position after a sequence of movements and the original point. If the distance is a float, then just print the nearest integer. | |
| Input Format: | |
| The first line of input consists of one string and one integer | |
| The second line of input consists of one string and one integer | |
| Same for the other new lines until the user enters a "STOP". | |
| Output Format: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #guessing game using python | |
| import random | |
| import math | |
| l=int(input("Enter lower boundary:")) | |
| h=int(input("Enter upper boundary:")) | |
| num = random.randint(l, h) | |
| x=h-l+1 | |
| a=int(math.log(x,2)) | |
| while True: | |
| print(f'Guess a number between {l} and {h}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| instructions=""" | |
| This is our TicTacToe Board | |
| 1 | 2 | 3 | |
| ---|---|--- | |
| 4 | 5 | 6 | |
| ---|---|--- | |
| 7 | 8 | 9 | |
| *Instructions: | |
| 1.Insert the number(1-9) | |
| 2.You Must fill all 9 spots to get the result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pour_water(juga,jugb): | |
| print("%d\t%d" % (juga,jugb)) | |
| if jugb == fill: | |
| return | |
| elif jugb == max2: | |
| pour_water(0,juga) | |
| elif juga != 0 and jugb == 0: | |
| pour_water(0,juga) | |
| elif juga == fill: | |
| pour_water(juga,0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def TowersofHonoi(n,source,destination,intermediate): | |
| if n == 1: | |
| print("Move disk from rod {} to rod {}".format(source,destination)) | |
| elif n == 0: | |
| return | |
| else: | |
| TowersofHonoi(n-1,source,intermediate,destination) | |
| print("Move disk from rod {} to rod {}".format(source,destination)) | |
| TowersofHonoi(n-1,intermediate,destination,source) | |
| n=int(input("Enter the no.of Disks:")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| letters='abcdefghijklmnopqrstuvwxyz' | |
| num_letters=len(letters) | |
| def encrypt_decrypt(text, mode, key): | |
| result='' | |
| if mode=='d': | |
| key=-key | |
| for letter in text: | |
| letter=letter.lower() | |
| if not letter==' ': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while True: | |
| def fun(): | |
| print("\n1.Manual\n2.Mathamatical\n3.Exit\n") | |
| mode=input("Choose choice:") | |
| print("\n") | |
| if mode == '1': | |
| letters='abcdefghijklmnopqrstuvwxyz' | |
| num_letters=len(letters) | |
| def encrypt_decrypt(text, mode, key): | |
| result='' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import string | |
| def generate_password(length, include_uppercase=True, include_lowercase=True, include_digits=True, include_punctuation=True, user_preference=''): | |
| # Define the characters to be used in the password based on user preferences | |
| characters = '' | |
| if include_uppercase: | |
| characters += string.ascii_uppercase | |
| if include_lowercase: | |
| characters += string.ascii_lowercase |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class StackCalculator: | |
| def __init__(self): | |
| self.stack = [] | |
| def push(self, num): | |
| self.stack.append(num) | |
| def pop(self): | |
| if not self.is_empty(): | |
| return self.stack.pop() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node: | |
| def __init__(self, value): | |
| self.value = value | |
| self.left = None | |
| self.right = None | |
| class BST: | |
| def __init__(self): | |
| self.root = None |
OlderNewer