This file contains 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 fact(n): | |
azam=1 | |
for c in range(1,n+1): | |
azam = azam*c | |
return azam | |
rows = int(input("Enter how many row you want to see :\n ")) | |
for i in range(0, rows): | |
for j in range(1, rows-i): | |
print(" ", end="") |
This file contains 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
love= input('enter a string ') | |
def rev(string): | |
d = dict() | |
for key in string: | |
if key not in d: | |
d[key] = 1 | |
else: | |
d[key] += 1 | |
return d |
This file contains 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 common_data(list1, list2): | |
result = False | |
for x in list1: | |
for y in list2: | |
if x == y: | |
result = True | |
return result | |
#azam | |
print("Enter elements of a list separated by space") | |
input_string1 = input('Enter Main list \n') |
This file contains 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
user_input = input("Enter a string:") | |
new_string = sorted(set(user_input)) | |
new_data = "".join(new_string) | |
print(new_data) |
This file contains 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 | |
n=int(input("Enter n value: ")) | |
random.seed(n) | |
m=random.randint(1,n) | |
print(m) | |
lis=[i for i in range(1,n+1)] | |
print(lis) | |
up_lis=[i for i in lis if i%m!=0] | |
print(up_lis) |
This file contains 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
''' When logging in the system, the user needs to first enter the account. If the account does not exist, output ”Wrong User" | |
and end the program; When the account number is correct, enter the password again to verify whether the account password is | |
consistent with the given account password. If it is consistent, output ”Success", otherwise output ”Fail" and the | |
remaining attempts. The total number of attempts is 3. If all three attempts are input incorrectly, ”Login Denied" is output.''' | |
dic={"aaa" : ["123456",10000],"bbb" : ["888888",5000],"ccc" : ["333333",3000]} | |
user_name=input("Enter User Name: ") | |
if user_name in dic.keys(): | |
for i in range(3): | |
pas=input("Enter Password: ") |
This file contains 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
n=int(input("Enter natural number greater then 2: ")) | |
primes = [] | |
for i in range (2, n): | |
for j in range(2, i): | |
if i%j == 0: | |
break | |
else: | |
primes.append(i) | |
print(primes) |
This file contains 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 = input("Enter Character: ") | |
result = ' '.join(sorted(str1)) | |
print(result, end=" ") |
This file contains 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 unique_list(text_str): | |
l = text_str.split() | |
temp = [] | |
for x in l: | |
if x not in temp: | |
temp.append(x) | |
return ' '.join(temp) | |
text_str = input("enter names: ") | |
print("Original String:") |
This file contains 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
''' There is a function f (x) defined on natural number, which is defined as | |
follows: | |
If x < 5, then f (x) = x; | |
If 5 < = x < 15, then f (x) = x + 6; | |
If x > = 15, then f (x) = x-6. | |
Try to write the function, enter the x value and return the corresponding f (x) | |
value. | |
[input form] the input line represents the natural number x. | |
[output form] the output line represents the calculation result f (x). If the | |
input data is illegal (e.g. negative integer), output "illegal input". |
OlderNewer