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 = input("Enter your name\n") | |
weight = float(input("Enter your weight\n")) | |
print("%s weighs %f kg" %(name,weight)) |
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 Robot: | |
power = 100 | |
defence = 70 |
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 reverse(name): | |
if len(name) <= 0: | |
return | |
reverse(name[1:]) | |
print(name[0], end='') | |
reverse("poppy") | |
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 spell_name(hits): | |
if hits == 0: | |
return | |
print("hit "+ str(hits)+" more times") | |
spell_name(hits -1 ) | |
spell_name(10) |
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
contender = 'Aliens' | |
def earth(): | |
global contender | |
contender = 'Avengers' | |
print( contender + ' ready for battle!') |
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 universe(): | |
contenders = ‘Fortem’ | |
print(‘outside Earth ’ + contender ) | |
def earth(): | |
contender = ‘Avengers’ | |
print(‘on Earth ’ + contender) | |
universe() | |
earth() |
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 shrink(height,door): | |
if(height <= door): | |
print("escape") | |
return | |
print("shrink") | |
height = height/2 | |
shrink(height,door) | |
shrink(8,2) | |
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
romantic={'Titanic','Holiday'} | |
comedy={'The Proposal','Spy'} | |
action={'Avatar','Spy'} | |
movies=romantic.union(comedy,action) | |
print(len(movies)) |
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
mobilePhones = "Shipped" | |
schoolBooks = "On Way" | |
print("status:") | |
print(mobilePhones, schoolBooks) |
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
schoolBooks = "On Way" | |
print(schoolBooks) | |
SchoolBooks = "Shipped" | |
print(SchoolBooks) |