Skip to content

Instantly share code, notes, and snippets.

View vihar's full-sized avatar
🚀

Vihar Kurama vihar

🚀
View GitHub Profile
for index in [1, 2, 3, 4, 5]:
print("{} times 5 is {}".format(index, index * 5))
flag = 10
while 0 < flag:
print(flag)
flag = flag - 1
print('Go !!')
for number in range(1, 7):
square = number * number
print(square)
# Declaring a function.
def greet():
print("Hello ! Welcome to the party.")
# calling the function.
greet()
def greet_name(name):
print("Hello {}".format(name))
greet_name("Flash")
greet_name("Arrow")
greet_name("Bat")
def num_factorial(num):
factorial = 1
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1, num + 1):
factorial = factorial * i
print("The factorial of number is {}" .format(factorial))
class Person():
def hello(self, name):
self.name = name
print("Hello {} How are you ?".format(self.name))
def bye(self, name):
self.name = name
print("Nice Meeting You {}".format(self.name))
class Person():
def __init__(self, name, year_of_birth):
self.name = name
self.year_of_birth = year_of_birth
def detail(self, name):
print("Name of the person is {}".format(name))
def age(self, year_of_birth):
class BankAccount:
def __init__(self):
self.balance = 0
def withdraw(self, amount):
self.balance -= amount
return print(self.balance)
def deposit(self, amount):
self.balance += amount
name = 'Stark'
job = "CEO at Queen’s Consolidate"
print(type(name))
print(type(job))
print(name, ",", job)