diff --git a/Conditional Expressions/Characters_In-Username.py b/Conditional Expressions/Characters_In-Username.py new file mode 100644 index 0000000..e73d2df --- /dev/null +++ b/Conditional Expressions/Characters_In-Username.py @@ -0,0 +1,6 @@ +a = str(input("Enter the username: ")) + +if len(a)<=10: + print("The username contains less than 10 characters") +else: + print("The uersname has more than 10 characters.") \ No newline at end of file diff --git a/Conditional Expressions/Checking_If_Age_Greater_Than_18.py b/Conditional Expressions/Checking_If_Age_Greater_Than_18.py new file mode 100644 index 0000000..b198da6 --- /dev/null +++ b/Conditional Expressions/Checking_If_Age_Greater_Than_18.py @@ -0,0 +1,6 @@ +a = int(input ("Enter your age: ")) + +if(a>18): + print ("Your age is more than 18.") +else: + print ("Your age is lesser than 18.") diff --git a/Conditional Expressions/Detect_Spam_Comment.py b/Conditional Expressions/Detect_Spam_Comment.py new file mode 100644 index 0000000..2a14a1e --- /dev/null +++ b/Conditional Expressions/Detect_Spam_Comment.py @@ -0,0 +1,13 @@ +a = ["make a lot of money", "buy now", "subscribe this", "click this"] +b = input("Enter the text here to check: ") + +if ("make a lot of money" in b): + print ("This is spam.") +elif("buy now" in b): + print("This is a spam.") +elif("subscribe this" in b): + print("This is a spam.") +elif("click this" in b): + print("This is a spam.") +else: + print ("This is not a spam.") \ No newline at end of file diff --git a/Conditional Expressions/Given_Name_In_List_Or_Not.py b/Conditional Expressions/Given_Name_In_List_Or_Not.py new file mode 100644 index 0000000..bea0eec --- /dev/null +++ b/Conditional Expressions/Given_Name_In_List_Or_Not.py @@ -0,0 +1,8 @@ +names = ["Amelia", "Benjamin", "Chloe", "Daniel", "Emily", "Finn", "Grace", "Henry", "Isabella", "Jacob"] + +a = input("Enter the name you want to search:\n") + +if a in names: + print("The name is in the list.") +else: + print("The name is not in the list.") diff --git a/Conditional Expressions/Grade_Calculation.py b/Conditional Expressions/Grade_Calculation.py new file mode 100644 index 0000000..a691d82 --- /dev/null +++ b/Conditional Expressions/Grade_Calculation.py @@ -0,0 +1,14 @@ +a = int(input("Enter the marks: ")) + +if (90d): + f1 = a +else: + f1 = d + +if (b>c): + f2 = b +else: + f2 = c + +if (f1>f2): + print (f1," is the greatest.") +else: + print (f2, " is the greatest.") diff --git a/Conditional Expressions/Pass_Or_Fail_On_Marks.py b/Conditional Expressions/Pass_Or_Fail_On_Marks.py new file mode 100644 index 0000000..5bfa11b --- /dev/null +++ b/Conditional Expressions/Pass_Or_Fail_On_Marks.py @@ -0,0 +1,18 @@ +a = int(input("Enter the marks in % of the first subject: ")) +b = int(input("Enter the marks in % of the second subject: ")) +c = int(input("Enter the marks in % of the third subject: ")) + +if(a<=33): + print ("Fail") +else: + print ("Pass") + +if(b<=33): + print ("Fail") +else: + print ("Pass") + +if(c<=33): + print ("Fail") +else: + print ("Pass") \ No newline at end of file diff --git a/Conditional Expressions/Text having a specific name.py b/Conditional Expressions/Text having a specific name.py new file mode 100644 index 0000000..90a8c50 --- /dev/null +++ b/Conditional Expressions/Text having a specific name.py @@ -0,0 +1,7 @@ +a = input("Enter the post text: ") +name = "Jacob" #The name variable contains the text that needs to be searched. + +if name in a: + print("The given post is talking about Jacob.") +else: + print("The given post is not talking about Jacob.") diff --git a/Data Types & Variables/Addition.py b/Data Types & Variables/Addition.py new file mode 100644 index 0000000..c117b9b --- /dev/null +++ b/Data Types & Variables/Addition.py @@ -0,0 +1,6 @@ +a = input ("Enter the first number: ") +a = int (a) +b = input ("Enter the second number: ") +b = int (b) +c = a + b +print ("The sum of both the numbers is",c,".") diff --git a/Data Types & Variables/Average_of_2_numbers.py b/Data Types & Variables/Average_of_2_numbers.py new file mode 100644 index 0000000..71a0131 --- /dev/null +++ b/Data Types & Variables/Average_of_2_numbers.py @@ -0,0 +1,6 @@ +a = input ("Enter the first number: ") +a = int (a) +b = input ("Enter the second number: ") +b = int (b) +(a + b)/ 2 +print ("The average of the two numbers is", (a + b)/ 2,".") diff --git a/Data Types & Variables/Remainder.py b/Data Types & Variables/Remainder.py new file mode 100644 index 0000000..76cccdf --- /dev/null +++ b/Data Types & Variables/Remainder.py @@ -0,0 +1,6 @@ +a = input ("Enter the first number: ") +a = int (a) +b = input ("Enter the second number: ") +b = int (b) +a%b +print ("The remainder when first number is divided by second is",a%b,".") \ No newline at end of file diff --git a/Data Types & Variables/Square_of_Number.py b/Data Types & Variables/Square_of_Number.py new file mode 100644 index 0000000..ad6339f --- /dev/null +++ b/Data Types & Variables/Square_of_Number.py @@ -0,0 +1,4 @@ +a = input ("Enter the number:") +a = int (a) +a*a +print ("The square of the number is",a*a,".") \ No newline at end of file diff --git a/Data Types & Variables/Variable_Type.py b/Data Types & Variables/Variable_Type.py new file mode 100644 index 0000000..7784e4e --- /dev/null +++ b/Data Types & Variables/Variable_Type.py @@ -0,0 +1,2 @@ +a = "Harris" +print (type(a)) diff --git a/Dictionary & Sets/Adding_Elements_To_Dictionary.py b/Dictionary & Sets/Adding_Elements_To_Dictionary.py new file mode 100644 index 0000000..9ae2a14 --- /dev/null +++ b/Dictionary & Sets/Adding_Elements_To_Dictionary.py @@ -0,0 +1,19 @@ +Dict = {} + +a = input ("Enter your name: ") +b = input ("Enter your favourite language: ") +Dict.update ({a : b}) + +c = input ("Enter your name: ") +d = input ("Enter your favourite language: ") +Dict.update ({c : d}) + +e = input ("Enter your name: ") +f = input ("Enter your favourite language: ") +Dict.update ({e : f}) + +g = input ("Enter your name: ") +h = input ("Enter your favourite language: ") +Dict.update ({g : h}) + +print (Dict) diff --git a/Dictionary & Sets/Dictionary_With_English_Meanings.py b/Dictionary & Sets/Dictionary_With_English_Meanings.py new file mode 100644 index 0000000..8880159 --- /dev/null +++ b/Dictionary & Sets/Dictionary_With_English_Meanings.py @@ -0,0 +1,13 @@ +Dict = { + "haal" : "deed", + "acha" : "good", + "bura" : "bad", + "sahih" : "ok", + "par" : "wings", +} + +a = input("Enter the word you want to search: ") + +meaningOfA = Dict.get(a) + +print (meaningOfA) \ No newline at end of file diff --git a/Dictionary & Sets/Display_Numers_Once.py b/Dictionary & Sets/Display_Numers_Once.py new file mode 100644 index 0000000..5c75eea --- /dev/null +++ b/Dictionary & Sets/Display_Numers_Once.py @@ -0,0 +1,20 @@ +s = set () + +a = input ("Enter the number you want to add: ") +s.add(a) +b = input ("Enter the number you want to add: ") +s.add(b) +c = input ("Enter the number you want to add: ") +s.add(c) +d = input ("Enter the number you want to add: ") +s.add(d) +e = input ("Enter the number you want to add: ") +s.add(e) +f = input ("Enter the number you want to add: ") +s.add(f) +g = input ("Enter the number you want to add: ") +s.add(g) +h = input ("Enter the number you want to add: ") +s.add(h) + +print (s) diff --git a/Dictionary & Sets/Int+String_In_Set.py b/Dictionary & Sets/Int+String_In_Set.py new file mode 100644 index 0000000..e2afeda --- /dev/null +++ b/Dictionary & Sets/Int+String_In_Set.py @@ -0,0 +1,2 @@ +s = {18, "18"} +print (s) \ No newline at end of file diff --git a/Dictionary & Sets/Length_Of_Set.py b/Dictionary & Sets/Length_Of_Set.py new file mode 100644 index 0000000..5a9b41b --- /dev/null +++ b/Dictionary & Sets/Length_Of_Set.py @@ -0,0 +1,7 @@ +s = set () + +s.add (20) +s.add (20.0) +s.add ("20") + +print (s) diff --git a/Dictionary & Sets/Type_Of_Set.py b/Dictionary & Sets/Type_Of_Set.py new file mode 100644 index 0000000..abd6e1e --- /dev/null +++ b/Dictionary & Sets/Type_Of_Set.py @@ -0,0 +1,2 @@ +s = {} +print (type (s)) diff --git a/Lists And Tuples/Changing_Tuple_Elements.py b/Lists And Tuples/Changing_Tuple_Elements.py new file mode 100644 index 0000000..fe26483 --- /dev/null +++ b/Lists And Tuples/Changing_Tuple_Elements.py @@ -0,0 +1,6 @@ +a = (2, 5, 89, 56, 4) + +a[0] = 4 +a[1] = 6 + +print (a) diff --git a/Lists And Tuples/Count_0s.py b/Lists And Tuples/Count_0s.py new file mode 100644 index 0000000..fbe67b0 --- /dev/null +++ b/Lists And Tuples/Count_0s.py @@ -0,0 +1,5 @@ +a = (7, 0, 8, 0, 0, 9) + +a.count(0) + +print (a.count(0)) \ No newline at end of file diff --git a/Lists And Tuples/Marks_Of_6_Students.py b/Lists And Tuples/Marks_Of_6_Students.py new file mode 100644 index 0000000..400e90e --- /dev/null +++ b/Lists And Tuples/Marks_Of_6_Students.py @@ -0,0 +1,11 @@ +a = int(input("Enter the marks of student no. 1: ")) +b = int(input("Enter the marks of student no. 2: ")) +c = int(input("Enter the marks of student no. 3: ")) +d = int(input("Enter the marks of student no. 4: ")) +e = int(input("Enter the marks of student no. 5: ")) +f = int(input("Enter the marks of student no. 6: ")) + +marks = [a, b, c, d, e, f] +marks.sort() + +print (marks) \ No newline at end of file diff --git a/Lists And Tuples/Storing Inputs In A List b/Lists And Tuples/Storing Inputs In A List new file mode 100644 index 0000000..a30b141 --- /dev/null +++ b/Lists And Tuples/Storing Inputs In A List @@ -0,0 +1,12 @@ +a = input ("Enter the name of the first fruit: ") +b = input ("Enter the name of the second fruit: ") +c = input ("Enter the name of the third fruit: ") +d = input ("Enter the name of the fourth fruit: ") +e = input ("Enter the name of the fifth fruit: ") +f = input ("Enter the name of the sixth fruit: ") +g = input ("Enter the name of the seventh fruit: ") + +Input = [a, b, c, d, e, f, g] + +print (Input) + diff --git a/Lists And Tuples/Sum_Of_List_Elements.py b/Lists And Tuples/Sum_Of_List_Elements.py new file mode 100644 index 0000000..7076bff --- /dev/null +++ b/Lists And Tuples/Sum_Of_List_Elements.py @@ -0,0 +1,4 @@ +a = [45, 25, 45, 65] + +print (a[0] + a[1] + a[2] + a[3]) #The sum is only the elemnts of the list. You can change the program if you want to sum the inputs entered by the user. + diff --git a/Loops In Python/Break_Statement_Function b/Loops In Python/Break_Statement_Function new file mode 100644 index 0000000..33d2117 --- /dev/null +++ b/Loops In Python/Break_Statement_Function @@ -0,0 +1,6 @@ +for i in range (0, 40): + print (i) + if i == 5: + break + +# The output is only till 5. diff --git a/Loops In Python/Continue_Statement_Function.py b/Loops In Python/Continue_Statement_Function.py new file mode 100644 index 0000000..a9d63ee --- /dev/null +++ b/Loops In Python/Continue_Statement_Function.py @@ -0,0 +1,4 @@ +for o in range (5): + if o == 3: + continue + print (o) diff --git a/Loops In Python/For_Loop_With_Else.py b/Loops In Python/For_Loop_With_Else.py new file mode 100644 index 0000000..a19a5af --- /dev/null +++ b/Loops In Python/For_Loop_With_Else.py @@ -0,0 +1,6 @@ +a = [1, 2, 3, 4, 5] + +for item in a: + print (item) +else: + print ("Done.") \ No newline at end of file diff --git a/Loops In Python/Greet_Person_With_S.py b/Loops In Python/Greet_Person_With_S.py new file mode 100644 index 0000000..4df7e19 --- /dev/null +++ b/Loops In Python/Greet_Person_With_S.py @@ -0,0 +1,8 @@ +#This program will only greet the person whose name starts with an "S". + +name = str(input("Enter the name: ")) + +if name.startswith ("S"): + print ("Greetings, " + name + "!") +else: + print ("Try again!!") \ No newline at end of file diff --git a/Loops In Python/Pass_Statement_Function.py b/Loops In Python/Pass_Statement_Function.py new file mode 100644 index 0000000..d2ea859 --- /dev/null +++ b/Loops In Python/Pass_Statement_Function.py @@ -0,0 +1,6 @@ +p = ["Apple", "Orange", "Banana", "Peach"] + +for item in p: + pass + +print ("HELLO!") \ No newline at end of file diff --git a/Loops In Python/Print_1_To_50_Using_While_Loop.py b/Loops In Python/Print_1_To_50_Using_While_Loop.py new file mode 100644 index 0000000..a736fe2 --- /dev/null +++ b/Loops In Python/Print_1_To_50_Using_While_Loop.py @@ -0,0 +1,5 @@ +a = 1 + +while a<=50: + print (str(a)) + a = a + 1 diff --git a/Loops In Python/Print_List_Contents_Using_While_Loop.py b/Loops In Python/Print_List_Contents_Using_While_Loop.py new file mode 100644 index 0000000..ff25a81 --- /dev/null +++ b/Loops In Python/Print_List_Contents_Using_While_Loop.py @@ -0,0 +1,6 @@ +a = ['John', 'Doe', 'Jane', 'Jacob', 'Joseph', 'Joshua'] +b = 0 + +while b +You are selected! + +Date: <|Date|> +''' + +name = input("Enter your name:") +date = input ("Enter date:") +letter = letter.replace("<|Name|>", name) +letter = letter.replace("<|Date|>", date) +print(letter)