Class – VII
Subject- Computer
L-7 Coding in Python
State whether these statements are true or false.
1) Is Python case sensitive when dealing with identifiers.
TRUE
2) Keywords can be used as identifiers. FALSE
3) Variable name can be of any length. TRUE
4) In python a variable must be declared before it is
assigned a value. FALSE
D
Download Python
Let’s Catch up
1) Which of this operator is used for addition of numbers
in python?
a) +
b) –
c) *
d) /
Ans: a) +
2) Which data type is used to store map values?
a) Int
b) String
c) Set
d) Dictionary
Ans: d) Dictionary
Exercise
A) Tick (ΓΌ) the correct option:
1) What will be the output of the following print (2**4+(5+5)**(1+1))
a) Error
b) 28
c) 118
d) 116
Ans: c) 118
2) What is the output of the code print(-18//4)
a) -4
b) 4
c) -5
d) 5
Ans: a) -4
3) Which of the following operators has the high precedence?
a) Not
b) &
c) *
d) +
Ans: c) *
4) Which one of these is floor division?
a) //
b) /
c) %
d) None of above
Ans: a) //
5) Which of the following is not keyword?
a) Eval
b) Assert
c) Pass
d) None
Ans: a) Eval
B) Fill in the blanks using the words from the help box:
[ Binary,
Relational, Reserve, Addition ]
1) Keyword are the reserve word.
2) Operator that work on two operands are called binary operator.
3) Relational are used for comparing two values.
4) In the expression 121+25 addition is the operator.
C) State ‘T’ for True or ‘F’ for False:
1) A Variable name consist of digits, alphabet and underscore.
TRUE
2) Keywords cannot be used as variable names. TRUE
3) Float data type is used to store Boolean values. FALSE
4) The input ( ) allows you to take input from users. FALSE
D) Short answer type questions:
1) What are keywords?
Ans: Keywords are reserved
words in Python with specific meanings.
2) Define the term operator?
Ans: An operator is a symbol
that represents an operation to be performed.
3) What is PEDMAS?
Ans: PEDMAS stands for
Parentheses, Exponents, Multiplication and Division (from left to right),
Addition and Subtraction (from left to right).
E) Long answer type questions:
1) What is the difference between Relation Operator and
Assignment operator?
Ans: Relational operators
compare values. Assignment operators assign values.
2) What is operator Precedence?
Ans: Operator precedence
defines the order in which operations are performed in an expression.
F) Let’s Solve:
1) Create a program using arithmetic operators.
Ans: a = 10
b = 5
sum_result
= a + b
print("Sum:",
sum_result)
2) Write a program to find the greatest number among
three numbers. Write their steps also.
Ans: num1 = 15
num2 =
20
num3 =
10
greatest
= max(num1, num2, num3)
print("Greatest
Number:", greatest)
G) Guess my name:
1) I am an operator that used for comparison.
Ans: Comparison Operator
2) I am an operator that used for sum.
Ans: Addition Operator
3) I am the reserve words.
Ans: Reserved Words
4) I am option used to store numeric values.
Ans: Integer
5) I am option used to store true and false.
Ans: Boolean
H) Tech Practice:
1) Write a program to find out the difference of two
given numbers.
Ans: num1 = 25
num2 = 15
difference = num1 - num2
print("Difference:",
difference)
2) Create a program to print message “good morning”.
Ans: print("Good morning!")
I) Demonstrate:
1) The use of operators with examples.
Ans: a = 10
b = 5
result = a + b
print("Result:", result)
2) Also demonstrate use of variables and data types.
Ans: name = "John"
age = 25
height = 1.75
is_student = True
print("Name:", name)
print("Age:", age)
print("Height:", height)
print("Is Student:",
is_student)
No comments:
Post a Comment