Chapter 2 Getting Started With Python
Chapter 2 Getting Started With Python
Q7. What is the difference between interactive mode and script mode in Python?
In interactive mode, instructions are given in front of Python prompt (>>> or In[ ]:) in
Python shell. Python carries out the given instruction and shows the result there itself.
In script mode, Python instructions are stored in a file with .py extension and are
executed together in one go as a unit known as Python program.
Page 1 of 6
COMPUTER SCIENCE WITH PYTHON
NOTE:
➢ Press F5 or Run → Run Module to run a program in script mode.
➢ Extension of python files is .py or .pyw
➢ Python is a case sensitive language as it treats upper and lower case
characters differently.
➢ Strings can come in single quotes(' ') or double quotes(" ")
➢ >>> is called as Python command prompt or prompt.
print( ) statement without any arguments will simply jump to the next line.
Page 2 of 6
COMPUTER SCIENCE WITH PYTHON
Python print Programs
# To print personal information like Name, Father’s Name, Class, School Name
print ("My name is Riya Verma")
print ("My Father’s name is Mr. Sunil Verma")
print ("I am in class XI")
print ("I study in CRPF Public School")
#to find the sum, product, difference and quotient of two entered numbers
num1=float(input("Enter first number "))
num2=float(input("Enter second number "))
print("The sum of two numbers is ", num1 + num2)
print("The difference of two numbers is ", num1 - num2)
print("The product of two numbers is ", num1 * num2)
print("The quotient of two numbers is ", num1 / num2)
#To read the temperature in Celsius and display it in Fahrenheit and Kelvin
c=float(input("Enter temperature in Celsius "))
f= c * 9/5 + 32
k= c + 273.15
print ("The temperature in Fahrenheit = " , f)
print ("The temperature in Kelvin = " , k)
Page 6 of 6