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
answer = 7 | |
print("Please guess a number between 1 to 10:") | |
guess = int(input()) | |
if guess < answer: | |
print("Enter a higher value") | |
guess = int(input()) | |
if guess == answer: | |
print("you have got on the first time") |
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
print(B'techyrick.tech dude \xE2\x9C\x85'.decode("utf-8")) |
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
list_1 = [1, 2, 1, 4, 6, 5, 7, 9] | |
print(list(set(list_1))) |
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
count = 0 | |
my_string = "Programiz" | |
my_char = "r" | |
for i in my_string: | |
if i == my_char: | |
count += 1 | |
print(count) |
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 time | |
def countdown(time_sec): | |
while time_sec: | |
mins, secs = divmod(time_sec, 60) | |
timeformat = '{:02d}:{:02d}'.format(mins, secs) | |
print(timeformat, end='\r') | |
time.sleep(1) | |
time_sec -= 1 |
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 get_permutation(string, i=0): | |
if i == len(string): | |
print("".join(string)) | |
for j in range(i, len(string)): | |
words = [c for c in string] | |
# swap |
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
my_string = "Always Techyrick" | |
cap_string = my_string.capitalize() | |
print(cap_string) |
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
str1 = "follow" | |
str2 = "r" | |
# convert both the strings into lowercase | |
str1 = str1.lower() | |
str2 = str2.lower() | |
# check if length is same | |
if(len(str1) == len(str2)): |
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
num = 34526666666666666666666666666 | |
count = 0 | |
while num != 0: | |
num //= 10 | |
count += 1 | |
print("Number of digits: " + str(count)) |
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
base = 36 | |
exponent = 55 | |
result = 1 | |
while exponent != 0: | |
result *= base | |
exponent-=1 | |
print("Answer = " + str(result)) |
NewerOlder