Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion basics/01_introduction/01_hello_world.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
print("ram")
print("Hello World")
print("Hello World")
2 changes: 2 additions & 0 deletions basics/01_introduction/04_mad_libs_story_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" This program generates a fun story by asking the user for different types of words"""


def mad_libs_story():
# Ask the user for words
name = input("Enter a name: ")
Expand All @@ -25,6 +26,7 @@ def mad_libs_story():
# Print the story
print(story)


# Run the story generator
if __name__ == "__main__":
mad_libs_story()
2 changes: 1 addition & 1 deletion basics/02_variables_types/01_arithmetic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Addition of Two Numbers
first_number = int(input("Enter the Number : "))
second_number = int(input("Enter the Number : "))
print(f"Addition of {first_number} and {second_number} is {first_number + second_number}")
print(f"Addition of {first_number} and {second_number} is {first_number + second_number}")
2 changes: 1 addition & 1 deletion basics/02_variables_types/05_square_input.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
number = int(input("Enter the First Number : "))
print(f"Square of {number} is {number ** 2}")
print(f"Square of {number} is {number ** 2}")
4 changes: 3 additions & 1 deletion basics/02_variables_types/06_convert_inches_cm.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Write a python function which converts inches to cms


def inch_cm(n):
inch = n * 2.54
return inch


n = int(input("Enter the Number : "))
ch = inch_cm(n)
print(ch)
print(ch)
5 changes: 4 additions & 1 deletion basics/02_variables_types/07_global_variable.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
a = 1000


def code():
global a #The global keyword allows a function to modify a global variable.
global a # The global keyword allows a function to modify a global variable.
a = 12
print(a)


code()
print(a)
4 changes: 2 additions & 2 deletions basics/02_variables_types/08_input_validation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
user_input = input(12) #Type of Input()
user_input = input(12) # Type of Input()
input_type = type(user_input)
print(input_type)
print(input_type)
9 changes: 4 additions & 5 deletions basics/02_variables_types/09_typecasting.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
print("1.")
a = "12.009" #String
b = float(a) #String to Float
a = "12.009" # String
b = float(a) # String to Float
print(type(b))

print("2.")
a = "12b" #String
"""b = float(a) """ #Error-Occured @TypeError
a = "12b" # String
"""b = float(a) """ # Error-Occured @TypeError
print(type(b))

print("3.")
z = "123"
b = int(z)
print(type(b))

21 changes: 13 additions & 8 deletions basics/02_variables_types/10_union_types.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#Maybe the Program not work but you just see the types like how union used in the program by import typing
# Maybe the Program not work but you just see the types like how union used
# in the program by import typing

from typing import List, Union, Tuple
def sum(a:Union[int,str],b:int) -> int:
sum = a+b


def sum(a: Union[int, str], b: int) -> int:
sum = a + b
return sum
a = sum(2,3)
print(a)


a = sum(2, 3)
print(a)

n : int = 5
n: int = 5
name: str = "Harry"
def sum(a: int, b: int) -> int:
return a+b


def sum(a: int, b: int) -> int:
return a + b
26 changes: 13 additions & 13 deletions basics/02_variables_types/11_operators.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#Comparison Operator
a=(4/2)==2
# Comparison Operator
a = (4/2) == 2
print(a)

#Assignment Operator
# Assignment Operator
a = 20
a=a+10 # or a += 10
a = a + 10 # or a += 10
print(a)

#Logical Operators
# Logical Operators
print("\n")
print("Truth Table of 'or'")
print("True or True : ",True or True)
print("True or False: ",True or False)
print("False or False: ",False or False)
print("False or True: ",False or True)
print("True or True : ", True or True)
print("True or False: ", True or False)
print("False or False: ", False or False)
print("False or True: ", False or True)
print("\n")
print("Truth Table of 'and'")
print("True and True : ",True and True)
print("True and False: ",True and False)
print("False and False: ",False and False)
print("False and True: ",False and True)
print("True and True : ", True and True)
print("True and False: ", True and False)
print("False and False: ", False and False)
print("False and True: ", False and True)
6 changes: 3 additions & 3 deletions basics/02_variables_types/12_celsius_fahrenheit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
def checktemp(c):
f = (c * 9/5) + 32
return f"{f}° Farenheit"


l = []
count = 0
while True:
a = int(input("Enter the Temperature in Celcius : "))
l.append(a)
count+=1
count += 1
if(count==1):
break
a = l[0]
print(f"Your Number :{a}")
faren = checktemp(a)
print(faren)


2 changes: 1 addition & 1 deletion basics/02_variables_types/13_escape_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# If we use double quote or single quote with "\" it act as same
Class = "How are you ? \"hope you are fine\" "
Roll = 'How are you ? \'hope you are fine\' '
print(name,Class,Roll)
print(name, Class, Roll)
3 changes: 2 additions & 1 deletion basics/03_control_flow/01_if_else.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
elif age < 0:
print("I think you come from the Past!")
else:
print("You are a Junior")
print("You are a Junior")

6 changes: 3 additions & 3 deletions basics/03_control_flow/04_multiplication_loop.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Write a program to print multiplication table of a given number using loops.

#Using ForLoops
# Using ForLoops
number = int(input("Enter the number : "))
for multiplier in range(10):
print(f"{number} * {multiplier + 1} = {number * (multiplier + 1)} ")

counter = 1
#Using WhileLoops
# Using WhileLoops
number = int(input("Enter the number : "))
while(counter < 11):
while counter < 11:
print(f"{number} * {counter} = {number * counter}")
counter = counter + 1

1 change: 0 additions & 1 deletion basics/03_control_flow/051_hello_10_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

for i in range(10):
print("Hello World")

3 changes: 2 additions & 1 deletion basics/03_control_flow/05_reverse_table.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
number = int(input("Enter Your Number :"))
for multiplier in range(1, 11):
print(f"{number}*{11 - multiplier}={number * (11 - multiplier)}")
print(f"{number}*{11 - multiplier}={number * (11 - multiplier)}")

5 changes: 3 additions & 2 deletions basics/03_control_flow/06_greet_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
l = ["Harry", "Soham", "Sachin", "Rahul","Harish","Hetbe","Rajesh","Harish Meheta"]"""


names_list = ["Harry", "Soham", "Sachin", "Rahul","Harish","Hetbe","Rajesh","Harish Meheta"]
names_list = ["Harry", "Soham", "Sachin", "Rahul", "Harish", "Hetbe", "Rajesh",
"Harish Meheta"]
for name in names_list:
if(name.startswith("H")):
if name.startswith("H"):
print(f"Greet Sended to {name}")
6 changes: 3 additions & 3 deletions basics/03_control_flow/08_pattern_pyramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

rows = int(input("Enter the Number : "))
for row in range(1, rows + 1):
print(" "* (rows - row), end="")
print("*"* (2 * row - 1), end="")
print(" ")
print(" " * (rows - row), end="")
print("*" * (2 * row - 1), end="")
print(" ")
4 changes: 2 additions & 2 deletions basics/03_control_flow/09_pattern_hollow_square.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

size = int(input("Enter the Number :"))
for row in range(1, size + 1):
if(row == 1 or row == size):
if row == 1 or row == size:
print(f"*" * size, end="")
else:
print(f"*", end="")
print(f" " * (size - 2), end="")
print(f"*", end="")
print("")
print("")
35 changes: 18 additions & 17 deletions basics/03_control_flow/10_if_else_challenges.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""QuestionNo1. Write a program to find the greatest of four numbers entered by the user."""

user_input = input("Enter Four Number ")
first_num = user_input.split(" ").pop(0)
second_num = user_input.split(" ").pop(1)
Expand All @@ -9,13 +10,13 @@
second_num = int(second_num)
third_num = int(third_num)
fourth_num = int(fourth_num)
if(first_num >= second_num and first_num >= third_num and first_num >= fourth_num):
if first_num >= second_num and first_num >= third_num and first_num >= fourth_num:
print(f"{first_num}")
elif(second_num >= second_num and second_num >= third_num and third_num >= fourth_num):
elif second_num >= second_num and second_num >= third_num and third_num >= fourth_num:
print(f"{second_num}")
elif(third_num >= second_num and third_num >= third_num and third_num >= fourth_num):
elif third_num >= second_num and third_num >= third_num and third_num >= fourth_num:
print(f"{third_num}")
elif(fourth_num >= first_num and fourth_num >= third_num and fourth_num >= second_num):
elif fourth_num >= first_num and fourth_num >= third_num and fourth_num >= second_num:
print(f"{fourth_num}")
else:
print("Invalid Number ! Choose Any Valid Number")
Expand All @@ -32,9 +33,9 @@
science_marks = marks_input.split(" ").pop(2)
print(f"Your Report")
total_marks = int(maths_marks) + int(social_science_marks) + int(science_marks)
if(total_marks > 120):
if total_marks > 120:
print(f"\tYour Marks {total_marks} Out of 300")
if(int(maths_marks) >= 33 and int(social_science_marks) >= 33 and int(science_marks) >= 33):
if int(maths_marks) >= 33 and int(social_science_marks) >= 33 and int(science_marks) >= 33:
print(f"You Passes\nMathematics : {maths_marks}\nSocial Science : {social_science_marks}\nScience : {science_marks}")
else:
print("Go and Study !")
Expand All @@ -54,7 +55,7 @@
characters or not."""

username = input("Enter your Username : ")
if(len(username) < 10):
if len(username) < 10:
print("Less than 10 characters ")
else:
print("More than or Equals to 10 characters ")
Expand All @@ -67,15 +68,15 @@
user_name = input("Enter Your Name : ")
name_count = names_list.count(user_name)
print(name_count)
if(name_count == 0):
if name_count == 0:
print("Not Present ")
elif(name_count != 0):
elif name_count != 0:
print("Present")
else:
print("Bla Bla Bla")

# type2
if(user_name in names_list):
if user_name in names_list:
print("Yes")
else:
print("no")
Expand All @@ -91,15 +92,15 @@
<=50 => Failed"""

student_marks = int(input("Enter your Marks : "))
if(student_marks >= 90 and student_marks <= 100):
if student_marks >= 90 and student_marks <= 100:
print(f"{student_marks}% Excellent")
elif(student_marks >= 80 and student_marks < 90):
elif student_marks >= 80 and student_marks < 90:
print(f"{student_marks}% Grade A")
elif(student_marks >= 70 and student_marks < 80):
elif student_marks >= 70 and student_marks < 80:
print(f"{student_marks}% Grade C")
elif(student_marks >= 60 and student_marks < 70):
elif student_marks >= 60 and student_marks < 70:
print(f"{student_marks}% Grade D")
elif(student_marks <= 50):
elif student_marks <= 50:
print(f"{student_marks}% You Failed")
else:
print(" Invalid Try again")
Expand All @@ -108,8 +109,8 @@
"""QuestionNo6. Write a program to find out whether a given post is talking about "Harry" or not."""

post_content = input("Enter Your Post : ").split(" ")
if("harry".lower() in post_content.lower()):
if "harry".lower() in post_content.lower():
result = "Yes Present"
else:
result = "No Not-Present"
print(post_content)
print(post_content)
1 change: 1 addition & 0 deletions basics/04_functions/01_functions_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ def add():
total = first_number + second_number
print(total)


for iteration in range(1, 6):
add()
3 changes: 2 additions & 1 deletion basics/04_functions/02_arguments_return.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#Function With Arguments and Using of Return
# Function With Arguments and Using of Return

def avg(first_num, second_num, message):
total = first_num + second_num
return f"{total} {message}"


result = avg(message="kidding", first_num=3, second_num=4)
print(result)
6 changes: 3 additions & 3 deletions basics/04_functions/03_find_greatest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ def greatest(first_num, second_num, third_num):
return f"{third_num} is Greater among {first_num} and {second_num}"
else:
return f"Invalid Numbers : {first_num}{second_num}{third_num} "


count = 0
numbers_list = []
while True:
number = int(input("Enter the Numbers : "))
numbers_list.append(number)
count += 1
if(count == 3):
if count == 3:
break
print(f"ok! I Found Your Numbers : {numbers_list}")
first_num = numbers_list[0]
second_num = numbers_list[1]
third_num = numbers_list[2]
result = greatest(first_num, second_num, third_num)
print(f"{result}")


Loading