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
for index in [1, 2, 3, 4, 5]: | |
print("{} times 5 is {}".format(index, index * 5)) |
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
flag = 10 | |
while 0 < flag: | |
print(flag) | |
flag = flag - 1 | |
print('Go !!') |
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
for number in range(1, 7): | |
square = number * number | |
print(square) |
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
# Declaring a function. | |
def greet(): | |
print("Hello ! Welcome to the party.") | |
# calling the function. | |
greet() |
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 greet_name(name): | |
print("Hello {}".format(name)) | |
greet_name("Flash") | |
greet_name("Arrow") | |
greet_name("Bat") |
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 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)) |
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
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)) | |
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
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): |
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
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 |
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
name = 'Stark' | |
job = "CEO at Queen’s Consolidate" | |
print(type(name)) | |
print(type(job)) | |
print(name, ",", job) |