REVIEW-XG
Good Morning boys.
In this session, we will check our understanding of Basic programing skills.
Link for today's Class:
By the end of the session, you will be able to
- Understand and apply the basic and output functions
- Create numeric and string variables
- Apply the concept of assignment and shorthand operators
- Apply the concept of relational and arithmatic operators
- Apply the concept of IF statements to solve the problems at hand
Write the Python commands to do the following:
Q1. Insert
the missing part of the code below
a. to output "Hello
World".
b. To write a comment “
program to test your knowledge” in the single line.
c. To write a multi-line
comment
Program to
Test your
Knowledge
d. Create a variable
named carname and assign the
value Volvo to it.
e. Create a variable
named x and assign the value 50 to it.
f. Display the sum
of 5 + 10, using two variables: x and y.
g. Create a variable
called z, assign x
+ y to
it, and display the result.(let x=10,y=5)
h. Get the characters
from index 2 to index 4 (llo).
txt ="Hello World"
x =
Q2.Follow the
instructions and do the needful:
a. Remove
the illegal characters in the variable name:
2my-first_name = "John"
b. Insert the correct
syntax to assign the same value to all three variables in one code line.
x y z
"Orange"
c. Insert the correct syntax
to convert x into a decimal number.
x = 5
x = (x)
d. Insert
the correct syntax to convert x into a integer.
x = 5.5
x = (x)
e. Correct the error in the
following statement:
if 5 > 2:
print("Five is greater than two!")
Q 3. What will be the output:
a.
x =
5
print(type(x))
b.
x = "Hello World"
print(type(x))
c.
x = 20.5
print(type(x))
Q4.Write commands to do the following ( If based questions):
a. Print "Hello
World" if a is greater
than b.
b. Print "Hello
World" if a is not equal
to b.
c. Print "Yes"
if a is equal to b,
otherwise print "No".
a = 50
b = 10
a b
print("Yes")
print("No")
d. Print "1"
if a is equal to b, print
"2" if a is greater
than b, otherwise print
"3".
a
= 50
b = 10
a b
print("1")
a b
print("2")
print("3")
e.
Print "Hello" if a is
equal to b, and c is
equal to d.
if a
== b c == d:
print("Hello")
f.
Print "Hello" if a is
equal to b, or if c is
equal to d.
if a == b c
== d:
print("Hello")
Good morning ma'am
ReplyDeleteToday you were late for class
ReplyDeleteWho???
DeleteGood morning ma'am
ReplyDeleteTejas
Good morning Mam
ReplyDelete-Aaron David
Excellent tejas and Brian. Keep up the good work
ReplyDeleteGood morning ma'am
ReplyDeleteRahul