Open your replit account: https://replit.com/~
for f in ["Joe", "Zoe", "Brad", "Angelina", "Zuki", "Thandi", "Paris"]:
invitation = "Hi " + f + ". Please come to my party on Saturday!"
print(invitation)
#write a program to print a msg from brightchamps
name=input("Enter Your name: ")
print("@"*20,"congratulations","@"*20)
print("\n")
print("It's time to celebrate! \n We're thrilled to tell you that ", name," has successfully completed the Thunkable of their BrightCHAMPS course. ")
print("*"*4,"Hurray!")
# format
x=10
y=5
sum=x+y
print("the sum of {} and {} is equal to {}".format(x,y,sum))
# multiplication table using format
print("welcome to multiplication table chat bot")
print("enter the number for printing the multiplication chat bot")
number=int(input())
for i in range(0,11):
print("{} X {} = {}".format(number,i,(i*number)))
#create variable and get input from user
name=input("Enter Name: ") #to get the input from user (*return a string value )
#math=input("Enter math score: ") #will show error need to convert the input from string to int
math=int(input("Enter math score: "))
science=int(input("Enter science score: "))
english=int(input("Enter english score: "))
max_marks=300
#printing the report card
print(10*"#"," REPORT CARD",10*"#")
print("\n","Student name: ",name)
print(30*"-")
print("math score: ",math)
print("science score: ",science)
print("english score: ",english)
print(30*"-")
total_marks=math+science+english
print("your total marks is ",total_marks," out of ",max_marks)
percent_marks=(total_marks/max_marks)*100
print("your percentage score is ", percent_marks)
#using if
#write a program to find greater number from two numbers
a = int(input("Enter a? "));
b = int(input("Enter b? "));
if a>b:
print("a is largest");
else:
print("b is largest");
# using if condition
#make a program to give access to only who has secret code
secret_code="charlie345"
name=input(" Enter your name")
user_code=input("please enter secret code ")
if (user_code==secret_code):
("Hello "+name+ "welcome to our secret society")
("you have access to our VIP programs")
else :
print("you are not allowed to access the program ")
# modify above program to make a calculator using if condition
a=int(input("Enter first number : "))
b=int(input("Enter second number: "))
print(" press 1 for addition \n press 2 for subraction \n press 3 to multiply \n press 4 for division")
choice=int(input("enter your choice "))
if (choice==1):
sum=a+b
print("sum = ",sum)
if (choice==2):
sub=a-b
print("subtraction = ",sub)
if (choice==3):
mul=a*b
print("MUltiplication = ",mul)
if (choice==4):
div=a/b
print("division = ",div)
# modify the same using if elif in next lesson
Next
#write a program check if a letter is a vowel or a consonant.
var=input("enter your letter ")
if var=="a":
print("this letter is a vowel")
elif var=="e":
print("this letter is e vowel")
elif var=="i":
print("this letter is i vowel")
elif var=="o":
print("this letter is o vowel")
elif var=="u":
print("this letter is u vowel")
else:
print("this letter is consonant")
# write a program to check the divisibility of number with 2 ,3 ,5
num=int(input("enter your letter "))
if num%2==0:
print(num,"is divisible by 2")
elif num%3==0:
print(num,"is divisible by 3")
elif num%5==0:
print(num,"is divisible by 5")
else:
print(num,"is not divisible by 2,3,5")
#write a program to find greater number from three numbers
a = int(input("Enter a? "));
b = int(input("Enter b? "));
c = int(input("Enter c? "));
if a>b and a>c:
print("a is largest");
elif b>a and b>c:
print("b is largest");
elif c>a and c>b:
print("c is largest");
#write a program to check the grade
marks = int(input("Enter the marks? "))
if marks > 85 and marks <= 100:
print("Congrats ! you scored grade A ...")
elif marks > 60 and marks <= 85:
print("You scored grade B ...")
elif marks > 40 and marks <= 60:
print("You scored grade c ...")
elif (marks > 30 and marks <= 40):
print("You scored grade D ...")
else:
print("Sorry you are fail ?")
If else
#program to explain the nested if conditions
print("Hi welcome to World Tour Bot")
print("Press 1 to visit Europe")
print("Press 2 to visit Asia")
print("Press 3 to visit South America")
#add more continents
choice=input("please enter your choice: ")
if(choice=="1"):
print("please enter the country you want to visit in Europe")
country=input()
if(country=="Finland"):
print("Welcome to the the Land of a thousand lakes")
elif(country=="Germany"):
print("Welcome to the Land of Poets and Thinkers")
elif(country=="France"):
print("Welcome to the Land of the Franns")
else:
print("please select from Finland, Germany and France")
elif(choice=="2"):
print("please enter the country you want to visit in Asia")
country=input()
if(country=="India"):
print("Welcome to the the Land of Mystery and Diversity")
elif(country=="Indonesia"):
print("Welcome to the Emerald of the Equator")
elif(country=="Japan"):
print("Welcome to the Land of Rising Sun")
else:
print("please select from India, Indonesia and Japan")
elif(choice=="3"):
print("please enter the country you want to visit in South America")
country=input()
if(country=="Bolivia"):
print("Welcome to the the Land of Silver")
elif(country=="Colombia"):
print("Welcome to the land of the the rhythm")
elif(country=="Peru"):
print("Welcome to the land of the Incas")
else:
print("please select from Bolivia, Colombia and Peru")
else:
print("please enter the proper input")
Math Random
import math
number1=math.sqrt(100) # calculate square root of 100
number2=math.sqrt(3)# calculate square root of 3
print(number1)
print(number2)
# math module
import math
x = math.ceil(1.4) # will returns the ceil value i.e the smallest integer greater than or equal to x.
y = math.floor(1.4) # will returns the floor value i.e the largest integer not greater than x.
print(x) # returns 2
print(y) # returns 1
print(math.sqrt(9)) # square root of 9
power=math.pow(2,4) # 2 power 4
print(power)
print(math.pi)
import math
number1=math.pow(2,4)
print(number1)
Finding Area 2D and 3D
Maxima and Minima
Rock, Scissors and Paper
Further more
import random
##Declare Variables
usernum=0
lottery_num=random.randint(0,10)
##Input
print("Welcome to the Lottery Program!")
usernum=int(input("Please enter a number between 1 - 10: "))
print("Calculating Results.")
if lottery_num==usernum:
print("All your numbers match in exact order! Your reward is $10,000!\n")
else:
print("Your numbers don't match! Sorry! Better luck next time")
# math module
import math
# for integers
print(round(15))
# for floating point
print(round(51.6)) # will round of the value to closest integer value
print(round(51.5))
print(round(51.4))
#area of circle
# radius of the circle
r = 4
# value of pie
pie = math.pi
# area of the circle
print(pie * r * r)
# program to calculate area of sphere
r=int(input("enter radius "))
p=math.pi
area= 4*p*r*r
print("surface area of sphere is ", area)
area=math.ceil(area)
print("surface area of sphere is ", area) #calculate the integer value
# factorial()
a = 5
# returning the factorial of 5
print("The factorial of 5 is : ", end="")
print(math.factorial(a))
#find min and max( in built math functions) no need to import math
x = min(5, 10, 25)
y = max(5, 10, 25)
print(x)
print(y)
x = pow(4, 3) #calculate the pow
print(x)
# ask the student about scientific calculator in phone/tablet what other things they know and make student find those values
# for degrees()
# Printing degrees equivalents.
print("1 Radians is equal to Degrees : ", end ="")
print (math.degrees(1))
# for radians
# Printing radians equivalents.
print("1 Degrees is equal to Radians : ", end ="")
print (math.radians(1))
#(optional)
# time module
import time
for i in range(3):
print("hello")
time.sleep(2) # in seconds
#print steps in programing cycle
print("%%Programming cycle%%")
time.sleep(2)
print("1.problem Analysis")
time.sleep(2)
print("2.Algorithm")
time.sleep(2)
print("3.coding")
time.sleep(2)
print("4.debugging")
time.sleep(2)
#datatime module
import datetime
x = datetime.datetime.now()
print(x) #year, month, day, hour, minute, second, and microsecond. UTC time
x = datetime.datetime.now()
# get year month and date
print(x.year)
print(x.month)
print(x.day)
# print the local time zone
from datetime import datetime
import pytz #import python time zone
# get the standard UTC time
UTC = pytz.utc
# it will get the time zone
# of the specified location
IST = pytz.timezone('Asia/Kolkata')
MYT=pytz.timezone('Asia/Kuala_Lumpur')
BST=pytz.timezone('Asia/Dhaka')
# print the date and time in
# standard format
print("UTC in Default Format : ",datetime.now(UTC))
print("IST in Default Format : ", datetime.now(IST))
print("MYT in Default Format : ", datetime.now(MYT))
print("BST in Default Format : ", datetime.now(BST))
#optional
dateIST=datetime.now(IST)
print(" year",dateIST.year)
print(" month",dateIST.month)
print(" date",dateIST.day)
print(" hour",dateIST.hour)
print(" minute",dateIST.minute)
print(" second",dateIST.second)
h=dateIST.hour
m=dateIST.minute
s=dateIST.second
y=dateIST.year
mon=dateIST.month
d=dateIST.day
print(h,":",m,":",s)# print time
print(d,"-",mon,"-",y) # print date
# same for other time zones
# code to get the time zone name for all the contries timezone()
#for tz in pytz.all_timezones:
# print tz