CameraIcon

Write the corresponding Python assignment statements: a) Assign 10 to variable length and 20 to variable breadth. b) Assign the average of values of variables length and breadth to a variable sum c) Assign a list containing strings ‘Paper’, ‘Gel Pen’, and ‘Eraser’ to a variable stationery. d) Assign the strings ‘Mohandas’, ‘Karamchand’, and ‘Gandhi’ to variables first, middle and last. e) Assign the concatenated value of string variables first, middle and last to variable fullname. Make sure to incorporate blank spaces appropriately between different parts of names.

A) length, breadth = 10,20 b) sum = (length + breadth)/2 c) stationary =[ 'paper' , 'gel pen' , 'eraser' ] d) first,middle,last = "mohandas" , "karamchand" , "gandhi" e) fullname = first + " " + middle + " " + last.

flag

Write the corresponding Python assignment statements: Assign 10 to variable length and 20 to variable breadth.

Q. write the corresponding python assignment statements:, (a) assign 10 to variable length and 20 to variable breadth., (b) assign the average of values of variables length and breadth to a variable sum., (c) assign a list containing strings ‘paper’, ‘gel pen’, and ‘eraser’ to a variable stationery., (d) assign the strings ‘mohandas’, ‘karamchand’, and ‘gandhi’ to variables first, middle and last., (e) assign the concatenated value of string variables first, middle and last to variable fullname. make sure to incorporate blank spaces appropriately between different parts of names., post a comment.

You can help us by Clicking on ads. ^_^ Please do not send spam comment : )

Contact form

  • Python Basics
  • Interview Questions
  • Python Quiz
  • Popular Packages
  • Python Projects
  • Practice Python
  • AI With Python
  • Learn Python3
  • Python Automation
  • Python Web Dev
  • DSA with Python
  • Python OOPs
  • Dictionaries
  • Memory Management in Python
  • Ways to increment Iterator from inside the For loop in Python
  • How to Break out of multiple loops in Python ?
  • Scope Resolution in Python | LEGB Rule
  • How to add Python to Windows PATH?
  • Benefits of Double Division Operator over Single Division Operator in Python
  • Specifying the increment in for-loops in Python
  • How to use Variables in Python3?
  • Check multiple conditions in if statement - Python
  • Difference between dir() and vars() in Python
  • Variables under the hood in Python
  • Understanding the Execution of Python Program
  • Viewing all defined variables in Python
  • Convert Python String to Float datatype
  • Python Main Function
  • What is the difference between Python's Module, Package and Library?
  • How to convert Float to Int in Python?
  • Context Variables in Python
  • Why does Python automatically exit a script when it’s done?

Different Forms of Assignment Statements in Python

We use Python assignment statements to assign objects to names. The target of an assignment statement is written on the left side of the equal sign (=), and the object on the right can be an arbitrary expression that computes an object.

There are some important properties of assignment in Python :-

  • Assignment creates object references instead of copying the objects.
  • Python creates a variable name the first time when they are assigned a value.
  • Names must be assigned before being referenced.
  • There are some operations that perform assignments implicitly.

Assignment statement forms :-

1. Basic form:

This form is the most common form.

2. Tuple assignment:

When we code a tuple on the left side of the =, Python pairs objects on the right side with targets on the left by position and assigns them from left to right. Therefore, the values of x and y are 50 and 100 respectively.

3. List assignment:

This works in the same way as the tuple assignment.

4. Sequence assignment:

In recent version of Python, tuple and list assignment have been generalized into instances of what we now call sequence assignment – any sequence of names can be assigned to any sequence of values, and Python assigns the items one at a time by position.

5. Extended Sequence unpacking:

It allows us to be more flexible in how we select portions of a sequence to assign.

Here, p is matched with the first character in the string on the right and q with the rest. The starred name (*q) is assigned a list, which collects all items in the sequence not assigned to other names.

This is especially handy for a common coding pattern such as splitting a sequence and accessing its front and rest part.

6. Multiple- target assignment:

In this form, Python assigns a reference to the same object (the object which is rightmost) to all the target on the left.

7. Augmented assignment :

The augmented assignment is a shorthand assignment that combines an expression and an assignment.

There are several other augmented assignment forms:

Please Login to comment...

Similar reads.

  • python-basics
  • Python Programs
  • 10 Ways to Use Microsoft OneNote for Note-Taking
  • 10 Best Yellow.ai Alternatives & Competitors in 2024
  • 10 Best Online Collaboration Tools 2024
  • 10 Best Autodesk Maya Alternatives for 3D Animation and Modeling in 2024
  • 30 OOPs Interview Questions and Answers (2024)

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

CS-IP-Learning-Hub

CS-IP-Learning-Hub

Important Questions and Notes

NCERT Solution Getting Started with Python Class 11 Chapter 5

Getting started with python class 11 ncert solution, q1. which of the following identifier names are invalid and why.

  • Total Marks
  • Total_Marks
  • total-Marks
  • _Percentage

Ans. Following identifier names are invalid

Q2. Write the corresponding Python assignment statements:

a) Assign 10 to variable length and 20 to variable breadth.

b) Assign the average of values of variables length and breadth to a variable sum.

c) Assign a list containing strings ‘Paper’, ‘Gel Pen’, and ‘Eraser’ to a variable stationery.

d) Assign the strings ‘Mohandas’, ‘Karamchand’, and ‘Gandhi’ to variables first, middle and last.

e) Assign the concatenated value of string variables first, middle and last to variable fullname. Make sure to incorporate blank spaces appropriately between different parts of names.

Ans. a) length = 10

breadth = 20

OR (we can also assign values in a single line)

length , breadth = 10, 20

b) sum = (length + breadth)/2

c) stationery = [‘Paper’, ‘Gel Pen’, ‘Eraser’]

d) first, middle, last = ‘Mohandas’, ‘Karamchand’, ‘Gandhi’

e) fullname = first + ” ” + middle + ” ” + last

Q3. Write logical expressions corresponding to the following statements in Python and evaluate the expressions (assuming variables num1, num2, num3, first, middle, last are already having meaningful values):

a) The sum of 20 and –10 is less than 12.

b) num3 is not more than 24.

c) 6.75 is between the values of integers num1 and num2.

d) The string ‘middle’ is larger than the string ‘first’ and smaller than the string ‘last’.

e) List Stationery is empty

Q4. Add a pair of parentheses to each expression so that it evaluates to True.

a) 0 == 1 == 2

b) 2 + 3 == 4 + 5 == 7

c) 1 < -1 == 3 > 4

Ans. a) (0 == (1 == 2) )

b) ( (2 + (3 == 4) + 5) == 7)

c) (1 < -1) == (3 > 4)

Q5. Write the output of the following:

a) num1 = 4

num2 = num1 + 1

print (num1, num2)

b) num1, num2 = 2, 6

num1, num2 = num2, num1 + 2

c) num1, num2 = 2, 3

num3, num2 = num1, num3 + 1

print (num1, num2, num3)

Ans. a) 2, 5

c) NameError: name ‘num3’ is not defined

Q6. Which data type will be used to represent the following data values and why?

a) Number of months in a year

b) Resident of Delhi or not

c) Mobile number

d) Pocket money

e) Volume of a sphere

f) Perimeter of a square

g) Name of the student

h) Address of the student

a) int data type

b) Boolean data type

c) int data type

d) float data type

e) float data type

f) float data type

g) String data type

h) String data type

Q7. Give the output of the following when num1 = 4, num2 = 3, num3 = 2

a) num1 += num2 + num3 print (num1)

b) num1 = num1 ** (num2 + num3) print (num1)

c) num1 **= num2 + num3

d) num1 = ‘5’ + ‘5’

print(num1)

e) print(4.00/(2.0+2.0))

f) num1 = 2+9*((3*12)-8)/10

g) num1 = 24 // 4 // 2

h) num1 = float(10)

print (num1)

i) num1 = int(‘3.14’)

j) print(‘Bye’ == ‘BYE’)

k) print(10 != 9 and 20 >= 20)

l) print(10 + 6 * 2 ** 2 != 9//4 -3 and 29 >= 29/9)

m) print(5 % 10 + 10 < 50 and 29 <= 29)

n) print((0 < 6) or (not(10 == 6) and (10<0)))

c) Syntax Error

i) ValueError

Q8. Categorise the following as syntax error, logical error or runtime error:

b) num1 = 25; num2 = 0; num1/num2

Ans. a) Run Time Error (ZeroDivisionError: division by zero)

b) Run Time Error (ZeroDivisionError: division by zero)

Q9. A dartboard of radius 10 units and the wall it is hanging on are represented using a two-dimensional coordinate system, with the board’s centre at coordinate (0,0). Variables x and y store the x-coordinate and the y-coordinate of a dart that hits the dartboard. Write a Python expression using variables x and y that evaluates to True if the dart hits (is within) the dartboard, and then evaluate the expression for these dart coordinates: a) (0,0) b) (10,10) c) (6, 6) d) (7,8)

Ans. In this question we have to use the distance formula of chapter Co-ordinate Geometry of Class 10th.

Formula is sqrt((x2-x1)**2 +(y2 – y1) ** 2 )

In this question x1 and y1 is fixed ie 0 while x2 and y2 value is given.

If the distance calculated is more than 10, it means the dart is not hitting the dartboard.

Q10. Write a Python program to convert temperature in degree Celsius to degree Fahrenheit. If water boils at 100 degree C and freezes as 0 degree C, use the program to find out what is the boiling point and freezing point of water on the Fahrenheit scale. (Hint: T(°F) = T(°C) × 9/5 + 32)

Ans. Program to convert degree Celsius to degree Fahrenheit is

TC=0 TF=0 TC = int(input(“Enter temperature in degree Celcius”)) TF = 9/5*TC + 32 print(TF)

If input is 100 then output will be 212.0

If input is 0 then output will be 32.0

Q11. Write a Python program to calculate the amount payable if money has been lent on simple interest. Principal or money lent = P, Rate of interest = R% per annum and Time = T years. Then Simple Interest (SI) = (P x R x T)/ 100. Amount payable = Principal + SI. P, R and T are given as input to the program.

P=float(input(“Enter Principal”)) R= float(input(“Enter Rate of interest”)) T= float(input(“Enter Time”)) SI = (P * R * T)/100 A = P + SI print(“Amount to be paid is”, A)

Q12. Write a program to calculate in how many days a work will be completed by three persons A, B and C together. A, B, C take x days, y days and z days respectively to do the job alone. The formula to calculate the number of days if they work together is xyz/(xy + yz + xz) days where x, y, and z are given as input to the program.

x = int(input(“Enter number of days for A to finish work”)) y = int(input(“Enter number of days for B to finish work”)) z = int(input(“Enter number of days for C to finish work”)) s = x y + y z + z x d = x y*z/s print(“Number of days required to finish task together is “,d)

Q13. Write a program to enter two integers and perform all arithmetic operations on them.

a = int(input(“Enter First Number”)) b = int(input(“Enter Second Number”)) print(“Basic Mathematical Operations are”) print(“Addition is “, a+b) print(“Subtraction is “, a-b) print(“Division is “, a/b) print(“Product is “, a*b) print(“Advanced Mathematical Operations are”) print(“Modulus “, a%b) print(“Floor Division is “, a//b)

Q14. Write a program to swap two numbers using a third variable.

a = int(input(“Enter First Number”)) b = int(input(“Enter Second Number”)) print(“Before Swaping Values are”) print(“Value of First Variable a is “, a) print(“Value of Second Variable b is “, b) c = a a = b b = c print(“After Swaping Values are”) print(“Value of First Variable a is “, a) print(“Value of Second Variable b is “, b)

Q15. Write a program to swap two numbers without using a third variable.

a = int(input(“Enter First Number”)) b = int(input(“Enter Second Number”)) print(“Before Swaping Values are”) print(“Value of First Variable a is “, a) print(“Value of Second Variable b is “, b) a = a + b b = a – b a = a – b print(“After Swaping Values are”) print(“Value of First Variable a is “, a) print(“Value of Second Variable b is “, b)

a = int(input(“Enter First Number”)) b = int(input(“Enter Second Number”)) print(“Before Swaping Values are”) print(“Value of First Variable a is “, a) print(“Value of Second Variable b is “, b) a, b = b, a print(“After Swaping Values are”) print(“Value of First Variable a is “, a) print(“Value of Second Variable b is “, b)

Q16. Write a program to repeat the string ‘‘GOOD MORNING” n times. Here ‘n’ is an integer entered by the user.

n = int(input(“Enter how many times you want to repeat ?”)) print(“GOOD MORNING” * n)

Q17. Write a program to find average of three numbers.

num1 = int(input(“Enter First Number “)) num2 = int(input(“Enter Second Number “)) num3 = int(input(“Enter Third Number “)) avg = (num1 +num2 + num3)/3 print(“Average of three numbers is :”, avg)

Q18. The volume of a sphere with radius r is 4/3πr3. Write a Python program to find the volume of spheres with radius 7cm, 12cm, 16cm, respectively.

print(“Volume of a Sphere when radius is 7cm is “, 4/3 * 22/7 * 7 * 7* 7)

print(“Volume of a Sphere when radius is 12cm is “, 4/3 * 22/7 * 12 * 12 * 12)

print(“Volume of a Sphere when radius is 16cm is “, 4/3 * 22/7 * 16 * 16 * 16)

Q19. Write a program that asks the user to enter their name and age. Print a message addressed to the user that tells the user the year in which they will turn 100 years old.

nm = input(“Enter Your Name”) age = int(input(“Enter Your age”)) yr = 2021 + (100 – age) #Taking 2021 as Current Year print(nm,” :You will turn 100 in “,yr)

Q20. The formula E = mc2 states that the equivalent energy (E) can be calculated as the mass (m) multiplied by the speed of light (c = about 3×108 m/s) squared. Write a program that accepts the mass of an object and determines its energy.

m = int(input(“Enter mass”)) print(“Energy produced by given mass is “, m * ((3 * 10 ** 8) ** 2))

Q21. Presume that a ladder is put upright against a wall. Let variables length and angle store the length of the ladder and the angle that it forms with the ground as it leans against the wall. Write a Python program to compute the height reached by the ladder on the wall for the following values of length and angle: a) 16 feet and 75 degrees b) 20 feet and 0 degrees c) 24 feet and 45 degrees d) 24 feet and 80 degrees

import math length = int(input(“Enter the length of ladder: “)) angind = int(input(“Enter the angle in degree: “)) anginr = math.radians(angind) sin = math.sin(anginr) height = round(length * sin,2) print(“The height reached by ladder “,height)

Disclaimer : I tried to give you the correct “ Getting Started with Python Class 11 NCERT Solution ” , but if you feel that there is/are mistakes in the “ Getting Started with Python Class 11 NCERT Solution “ given above, you can directly contact me at [email protected] .

Python Fundamentals practice questions

100 Practice Questions on Python Fundamentals

write the corresponding python assignment statements

120+ MySQL Practice Questions

python list programs

90+ Practice Questions on List

python output based questions

50+ Output based Practice Questions

write the corresponding python assignment statements

100 Practice Questions on String

write the corresponding python assignment statements

70 Practice Questions on Loops

Computer Network

120 Practice Questions of Computer Network in Python

write the corresponding python assignment statements

70 Practice Questions on if-else

write the corresponding python assignment statements

40 Practice Questions on Data Structure

Class 12 Computer Science Sample Paper 2020-2021 .

Class 12 Computer Science Sample Paper Marking Scheme

Class 12 Computer Science Test Series

Leave a Reply Cancel reply

Question 1:

Which of the following identifier names are invalid and why?

i) Serial_no.: Invalid - Identifier in python cannot contain any special character except underscore(_). ii) 1st_Room: Invalid - Identifier in Python cannot start with a number. iii) Hundred$:  Invalid - Identifier in Python cannot contain any special character except underscore(_). iv) Total Marks: Invalid - Identifier in Python cannot contain any special character except underscore(_). If more than one word is used as a variable then it can be separated using underscore (  _  ), instead of space. v) Total_Marks: Valid vi) total-Marks: Invalid - Identifier in Python cannot contain any special character except underscore(_). If more than one word is used as a variable then it can be separated using underscore (  _  ), instead of a hyphen ( - ).

Page No 115:

Question 2:.

Write the corresponding Python assignment statements: a) Assign 10 to variable length and 20 to variable breadth. b) Assign the average of values of variables length and breadth to a variable sum c) Assign a list containing strings ‘Paper’, ‘Gel Pen’, and ‘Eraser’ to a variable stationery. d) Assign the strings ‘Mohandas’, ‘Karamchand’, and ‘Gandhi’ to variables first, middle and last. e) Assign the concatenated value of string variables first, middle and last to variable fullname. Make sure to incorporate blank spaces appropriately between different parts of names.

a) length, breadth = 10,20 b) sum = (length + breadth)/2 c) stationary =[ 'Paper' , 'Gel Pen' , 'Eraser' ] d) first,middle,last = "Mohandas" , "Karamchand" , "Gandhi" e) fullname = first + " " + middle + " " + last

Question 3:

Write logical expressions corresponding to the following statements in Python and evaluate the expressions (assuming variables num1, num2, num3, first, middle, last are already having meaningful values): a) The sum of 20 and –10 is less than 12. b) num3 is not more than 24 c) 6.75 is between the values of integers num1 and num2. d) The string ‘middle’ is larger than the string ‘first’ and smaller than the string ‘last’ e) List Stationery is empty

a) (20 + (-10)) < 12 b) num3 <= 24   or not(num3 > 24) c) (6.75 >= num1) and (6.75 <= num2) d) (middle > first) and (middle < last) e) len (Stationery) == 0

Page No 116:

Question 4:.

Add a pair of parentheses to each expression so that it evaluates to True. a) 0 == 1 == 2 b) 2 + 3 == 4 + 5 == 7 c) 1 < -1 == 3 > 4

a) ( 0 == (1==2)) b) (2 + (3 == 4) + 5) == 7 c) (1 < -1) == (3 > 4 )

Question 5:

Write the output of the following. a) num1 = 4   num2 = num1 + 1   num1 = 2   print (num1, num2) b) num1, num2 = 2, 6   num1, num2 = num2, num1 + 2   print (num1, num2) c) num1, num2 = 2, 3   num3, num2 = num1, num3 + 1   print (num1, num2, num3)

a) 2, 5 b) 6, 4 c) Error as num3 is used in RHS of line 2 ( num3, num2 = num1, num3 + 1 ) before defining it earlier.

Question 6:

Which data type will be used to represent the following data values and why? a) Number of months in a year b) Resident of Delhi or not c) Mobile number d) Pocket money e) Volume of a sphere f) Perimeter of a square g) Name of the student h) Address of the student

a) The int data type will be used to represent 'Number of months in a year' as it will be an integer i.e. 12. b) The boolean data type will be used to represent 'Resident of Delhi or not' as a person will be either a resident of Delhi or not a resident of Delhi. Therefore, the values True or False will be sufficient to represent the values. c) The integer data type will be used to represent 'Mobile number' as it will be a ten-digit integer only. d) The float data type will be used to represent 'Pocket money' as it can be in decimal. e.g Rs. 250.50 i.e 250 rupees and 50 paise. e) The float data type will be used to represent 'Volume of a sphere'. The formula for the volume of a sphere: Volume   of   sphere ,   V = 4 3 πr 3 Even if 'r' is a whole number, the value of volume can be a fraction which can be represented in a decimal form easily by float data type. f) The float data type will be used to represent 'Perimeter of a square'. The perimeter of a square: Perimeter = 4 × side length If the side length is a decimal number, the result may come out to be a decimal number which can be easily represented by float data type. Note:- If the side length is a whole number, the perimeter will always be an integer, however, we should be open to the possibility that the side length can be in decimal as well. g) The string data type will be used to represent 'Name of the student'. h)The string data type will be used to represent 'Address of the student'. However, if we have to store the address in a more structured format, we can use dictionary data type as well. e.g. Address = { 'Line1': ‘Address line 1', 'Line2':'Address Line2', 'Locality':'Locality Name', 'City':'City Name', 'Pincode':110001, 'Country':'India'}

Question 7:

Give the output of the following when num1 = 4, num2 = 3, num3 = 2 a) num1 += num2 + num3    print (num1) b) num1 = num1 ** (num2 + num3)   print (num1) c) num1 **= num2 + num3 d) num1 = '5' + '5'   print(num1) e) print(4.00/(2.0+2.0)) f) num1 = 2+9*((3*12)-8)/10   print(num1) g) num1 = 24 // 4 // 2   print(num1) h) num1 = float(10)     print (num1) i) num1 = int('3.14')   print (num1) j) print('Bye' == 'BYE') k) print(10 != 9 and 20 >= 20) l) print(10 + 6 * 2 ** 2 != 9//4 -3 and 29>= 29/9) m) print(5 % 10 + 10 < 50 and 29 <= 29) n) print((0 < 6) or (not (10 == 6) and (10<0)))

a) num1 += 3 + 2 The above statement can be written as num1 = num1 + 3 + 2 = 4 + 3 + 2 = 9 Therefore, print(num1) will give the output 9. b)  num1 = num1 ** (num2 + num3) The above statement will be executed as per the following steps. num1 = 4 ** (3 + 5) = 4 ** 5 = 1024 Therefore, print(num1) will give the output 1024. c) num1 **= num2 + num3 The above statement can be written as num1 **= 5 num1 = num1 ** 5 num1 = 4 ** 5 num1 = 1024 Therefore, the output will be 1024. d) num1 = '5' + '5' The RHS in the above statement is '5' + '5' . Please note that 5 is enclosed in quotes and hence will be treated as a string. Therefore, the first line is just a string concatenation which will give the output 55. The type of output will be a string, not an integer. e) print(4.00/(2.0 + 2.0)) The numbers written in the statement are in float data type therefore, the output will be also in float data type. print(4.00/(2.0 + 2.0)) print(4.0/4.0) 1.0 Therefore, the output will be 1.0. f) num1 = 2 + 9 * ((3 * 12) - 8) /10  # The expression within inner brackets will be evaluated first num1 = 2 + 9 * (36 - 8) /10  # The expression within outer brackets will be evaluated next          num1 = 2 + 9 * 28/10 # * and / are of same precedence, hence, left to right order is followed num1 = 2 + 252/10            num1 = 2 + 25.2            num1 = 27.2 Therefore, the output will be 27.2. g) num1 = 24 // 4 // 2 #When the operators are same, left to right order will be followed for operation num1 = 6 // 2    #When floor division is used, return value will be int data type      num1 = 3          Therefore, the output will be 3 h)  num1 = float(10) float(10) will convert integer value to float value and therefore, the output will be 10.0. i)  num1 = int('3.14') This will result in an error as we cannot pass string representation of float to an int function. j)  print('Bye' == 'BYE') As Python compares string character to character and when different characters are found then their Unicode value is compared. The character with lower Unicode value is considered to be smaller. Here, 'y' has Unicode 121 and 'Y' has 89. Therefore, the output will be 'False'. k) print(10 != 9 and 20 >= 20) print(True and True) print(True) Therefore, the output will be 'True'. l) print(10 + 6 * 2 ** 2 != 9//4 -3 and 29>= 29/9) Taking the above statement in two separate parts LHS: 10 + 6 * 2 ** 2 != 9//4 - 3 10 + 6 * 4 != 2 - 3 10 + 24 != -1 34 != -1 True RHS: 29 >= 29/9 True Now the complete equation can be written as print(True and True) Therefore, the output will be 'True'. m) print(5 % 10 + 10 < 50 and 29 <= 29) Taking the above statement in two separate parts LHS : 5 % 10 + 10 < 50 5 + 10 < 50 15 < 50 True RHS: 29 <= 29 True Now, the complete equation can be written as print(True and True) Therefore, the output will be 'True'. n) print( (0 < 6) or (not (10 == 6) and (10<0) ) ) print(True or (not False and False)) print(True or (True and False)) # not will be evaluated before and/or. print(True or False) print(True) Therefore, the output will be 'True'.

Page No 117:

Question 8:.

Categorise the following as syntax error, logical error or runtime error: a) 25 / 0 b) num1 = 25; num2 = 0; num1 / num2

a) Runtime Error. The syntax for the division is correct. The error will arise only when 'interpreter' will run this line. b) Runtime Error. The syntax is correct. The error will arise only when 'interpreter' will run the line containing these statements. 

Question 9:

A dartboard of radius 10 units and the wall it is hanging on are represented using a two-dimensional coordinate system, with the board’s centre at coordinate (0,0). Variables x and y store the x-coordinate and the y-coordinate of a dart that hits the dartboard. Write a Python expression using variables x and y that evaluates to True if the dart hits (is within) the dartboard, and then evaluate the expression for these dart coordinates: a) (0,0) b) (10,10) c) (6, 6) d) (7,8)

The distance formula can be used to calculate the distance between the points where the dart hits the dartboard and the centre of the dartboard.  The distance of a point P( x , y ) from the origin is given by x 2 + y 2 .  

To calculate the square root, the equation can be raised to the power 0.5.  Program: x = int ( input ( 'Enter X Coordinate: ' )) y = int ( input ( 'Enter Y Coordinate: ' )) dis = (x ** 2 + y ** 2) ** 0.5 #if dis is greater than 10, means that dart is more than 10 units away from the centre. print (dis <= 10) The output for the dart coordinates are as follows: a) (0,0): True b) (10,10): False c) (6,6): True d) (7,8): False  

Question 10:

Write a Python program to convert temperature in degree Celsius to degree Fahrenheit. If water boils at 100 degree C and freezes as 0 degree C, use the program to find out what is the boiling point and freezing point of water on the Fahrenheit scale. (Hint: T(°F) = T(°C) × 9/5 + 32)

Program: #defining the boiling and freezing temp in celcius boil = 100 freeze = 0 print ( 'Water Boiling temperature in Fahrenheit::' ) #Calculating Boiling temperature in Fahrenheit tb = boil * (9/5) + 32 #Printing the temperature print (tb) print ( 'Water Freezing temperature in Fahrenheit::' ) #Calculating Boiling temperature in Fahrenheit tf = freeze * (9/5) + 32 #Printing the temperature print (tf) OUTPUT: Water Boiling temperature  in Fahrenheit:: 212.0 Water Freezing temperature in Fahrenheit:: 32.0

Question 11:

Write a Python program to calculate the amount payable if money has been lent on simple interest. Principal or money lent = P, Rate of interest = R% per annum and Time = T years. Then Simple Interest (SI) = (P x R x T)/ 100. Amount payable = Principal + SI. P, R and T are given as input to the program.

Program: #Asking the user for Principal, rate of interest and time P = float ( input ( 'Enter the principal: ' )) R = float ( input ( 'Enter the rate of interest per annum: ' )) T = float ( input ( 'Enter the time in years: ' )) #calculating simple interest SI = (P * R * T)/100 #caculating amount = Simple Interest + Principal amount = SI + P #Printing the total amount print ( 'Total amount:' ,amount) OUTPUT:- Enter the principal: 12500 Enter the rate of interest per annum: 4.5 Enter the time in years: 4 Total amount: 14750.0

Page No 118:

Question 12:.

Write a program to calculate in how many days a work will be completed by three persons A, B and C together. A, B, C take x days, y days and z days respectively to do the job alone. The formula to calculate the number of days if they work together is xyz/(xy + yz + xz) days where x, y, and z are given as input to the program.

Program: #Asking for the number of days taken by A, B, C to complete the work alone x = int ( input ( 'Enter the number of days required by A to complete work alone: ' )) y = int ( input ( 'Enter the number of days required by B to complete work alone: ' )) z = int ( input ( 'Enter the number of days required by C to complete work alone: ' )) #calculating the time if all three person work together #formula used as per the question combined = (x * y * z)/(x*y + y*z + x*z) #rounding the answer to 2 decimal places for easy readability days = round (combined,2) #printing the total time taken by all three persons print ( 'Total time taken to complete work if A, B and C work together: ' , days) OUTPUT:- Enter the number of days required by A to complete work alone: 8 Enter the number of days required by B to complete work alone: 10 Enter the number of days required by C to complete work alone: 20 Total time taken to complete work if A, B and C work together: 3.64

Question 13:

Write a program to enter two integers and perform all arithmetic operations on them.

Program: #Program to input two numbers and performing all arithmetic operations #Input first number num1 = int ( input ("Enter first number: ")) #Input Second number num2 = int ( input ("Enter second number: ")) #Printing the result for all arithmetic operations print ( "Results:-" ) print ( "Addition: " ,num1+num2) print ( "Subtraction: " ,num1-num2) print ( "Multiplication: " ,num1*num2) print ( "Division: " ,num1/num2) print ( "Modulus: " , num1%num2) print ( "Floor Division: " ,num1//num2) print ( "Exponentiation: " ,num1 ** num2) OUTPUT: Enter first number: 8 Enter second number: 3 Results:- Addition:  11 Subtraction:  5 Multiplication:  24 Division:  2.6666666666666665 Modulus:  2 Floor Division:  2 Exponentiation:  512

Question 14:

Write a program to swap two numbers using a third variable.

Program: #defining two variables x = 5 y = 6 #printing the values before swapping print ( "The values of x and y are" ,x, "and" ,y, "respectively." ) # k is the third variable used to swap values between x and y k = x                         x = y y = k #printing the values after swapping print ( "The values of x and y after swapping are" ,x, "and" ,y, "respectively." ) OUTPUT: The values of x and y are 5 and 6 respectively. The values of x and y after swapping are 6 and 5 respectively.

Question 15:

Write a program to swap two numbers without using a third variable.

Program: #defining two variables x = 5 y = 6 #printing the values before swapping print ( "The values of x and y are" ,x, "and" ,y, "respectively." ) # Using 'multiple assignment' to swap the values x,y = y,x #printing the values after swapping print ( "The values of x and y after swapping are" ,x, "and" ,y, "respectively." ) OUTPUT: The values of x and y are 5 and 6 respectively. The values of x and y after swapping are 6 and 5 respectively.

Question 16:

Write a program to repeat the string ''GOOD MORNING'' n times. Here 'n' is an integer entered by the user.

The string will be repeated only if the value is greater than zero, otherwise, it will return a blank. Therefore, ‘if’ condition will be used to check the values of 'n' first and then the print statement will be executed. Program: str = "GOOD MORNING " n = int ( input ( "Enter the value of n: " )) if n>0:     print (str * n) else :     print ( "Invalid value for n, enter only positive values" ) OUTPUT: Enter the value of n: 5 GOOD MORNING GOOD MORNING GOOD MORNING GOOD MORNING GOOD MORNING

Question 17:

Write a program to find average of three numbers.

Program: #defining three variables a = 5 b = 6 c = 7 #calculating average using the formula, average = (sum of variables)/(number of variables) average = (a + b + c)/3 #print the result print ( "The average of" ,a,b, "and" ,c, "is" ,average) OUTPUT: The average of 5 6 and 7 is 6.0

Question 18:

The volume of a sphere with radius r is 4/3πr 3 . Write a Python program to find the volume of spheres with radius 7 cm, 12 cm, 16 cm, respectively.

Program: #defining three different radius using variables r1, r2, r3 r1 = 7 r2 = 12 r3 = 16 #calculating the volume using the formula volume1 = (4/3*22/7*r1**3) volume2 = (4/3*22/7*r2**3) volume3 = (4/3*22/7*r3**3) #printing the volume after using the round function to two decimal place for better readability print ( "When the radius is" ,r1, "cm, the volume of the sphere will be" , round (volume1,2)," cc ") print ( "When the radius is" ,r2, "cm, the volume of the sphere will be" , round (volume2,2)," cc ") print ( "When the radius is" ,r3, "cm, the volume of the sphere will be" , round (volume3,2)," cc ") OUTPUT: When the radius is 7 cm, the volume of the sphere will be 1437.33 cc When the radius is 12 cm, the volume of the sphere will be 7241.14 cc When the radius is 16 cm, the volume of the sphere will be 17164.19 cc

Question 19:

Write a program that asks the user to enter their name and age. Print a message addressed to the user that tells the user the year in which they will turn 100 years old.

Program: #Program to tell the user when they will turn 100 Years old name = input ( "Enter your name: " ) # age converted to integer for further calculation age = int ( input ( "Enter your age: " )) #calculating the 100th year for the user considering 2020 as the current year hundred = 2020 + (100 - age) #printing the 100th year print( "Hi" ,name, "! You will turn 100 years old in the year" ,hundred) OUTPUT: Enter your name: John Enter your age: 15 Hi John ! You will turn 100 years old in the year 2105

Question 20:

The formula E = mc 2 states that the equivalent energy (E) can be calculated as the mass (m) multiplied by the speed of light (c = about 3×10 8 m/s) squared. Write a program that accepts the mass of an object and determines its energy.

The formula is given as: E = mc 2 where, E ⇒ energy measured in Joule, m ⇒ mass in Kilogram, c ⇒ speed of light in m/s. Program: #Program to calculate the equivalent energy of an object #asking for the mass in grams mass = float ( input ( "Enter the mass of object(in grams): " )) #Speed of light is known and given in the question c = 3 * 10 ** 8 #calculating the energy, mass is divided by 1000 to convert it into kilogram Energy = (mass/1000) * c ** 2 #printing the output print( "The energy of an object with mass" ,mass, " grams is" ,Energy, "Joule." ) OUTPUT: Enter the mass of object(in grams): 25 The energy of an object with mass 25.0  grams is 2250000000000000.0 Joule.

Question 21:

Presume that a ladder is put upright against a wall. Let variables length and angle store the length of the ladder and the angle that it forms with the ground as it leans against the wall. Write a Python program to compute the height reached by the ladder on the wall for the following values of length and angle: a) 16 feet and 75 degrees b) 20 feet and 0 degrees c) 24 feet and 45 degrees d) 24 feet and 80 degrees

View NCERT Solutions for all chapters of Class 11

write the corresponding python assignment statements

Net Explanations

  • Book Solutions
  • State Boards

NCERT Solutions Class 11 Computer Science Chapter 5 Getting Started with Python

NCERT Solutions Class 11 Computer Science Chapter 5 Getting Started with Python: National Council of Educational Research and Training Class 11 Computer Science Chapter 5 Solutions – Getting Started with Python. NCERT Solutions Class 11 Computer Science Chapter 5 PDF Download.

NCERT Solutions Class 11 Computer Science Chapter 5: Overview

Question 1. Which of the following identifier names are invalid and why?

i Serial_no.                     v Total_Marks

ii 1st_Room                   vi total-Marks

iii Hundred$                   vii _Percentage

iv Total Marks                viii True

i) Serial_no. :- Invalid

Reason- (.) is not allowed in identifier

ii) 1st_Room :- Invalid

Reason- identifier can’t start with number

iii) Hundred$ :-  Invalid

Reason- We can’t use special symbol $ in identifier

iv) Total Marks :- Invalid

Reason- We can’t use space between in identifier

v) Total_Marks :- Valid

Reason- We can use underscore between in identifier

vi) total-Marks :- Invalid

Reason- We can’t use hyphen between in identifier

vii) _Percentage:- Invalid

Reason- Identifier can’t begin with underscore

viii) True :- Invalid

Reason- We can’t use keyword as a identifier

Question 2 . Write the corresponding Python assignment statements:

a) Assign 10 to variable length and 20 to variable breadth.

b) Assign the average of values of variables length and breadth to a variable sum.

c) Assign a list containing strings ‘Paper’, ‘Gel Pen’, and ‘Eraser’ to a variable stationery.

d) Assign the strings ‘Mohandas’, ‘Karamchand’, and ‘Gandhi’ to variables first, middle and last.

e) Assign the concatenated value of string variables first, middle and last to variable fullname. Make sure to incorporate blank spaces appropriately between different parts of names.

length = 10

breadth = 20

Sum = (length + breadth)/2

Stationary=[‘Paper’ ,  ‘Gel Pen’ , ‘Eraser’

first = ‘Mohandas’

middle= ‘Karamchand’

last= ‘Gandhi’

fullname = first +” “+ middle +” “+ last

Question 3. Write logical expressions corresponding to the following statements in Python and evaluate the expressions (assuming variables num1, num2, num3, first, middle, last are already having meaningful values):

a) The sum of 20 and –10 is less than 12.

b) num3 is not more than 24.

c) 6.75 is between the values of integers num1 and num2.

d) The string ‘middle’ is larger than the string ‘first’ and smaller than the string ‘last’.

e) List Stationery is empty.

Question 4. Add a pair of parentheses to each expression so that it evaluates to True.

a) 0 == 1 == 2

b) 2 + 3 == 4 + 5 == 7

c) 1 < -1 == 3 > 4

Question 5 . Write the output of the following:

a) num1 = 4

num2 = num1 + 1

print (num1, num2)

b) num1, num2 = 2, 6

num1, num2 = num2, num1 + 2

c) num1, num2 = 2, 3

num3, num2 = num1, num3 + 1

print (num1, num2, num3)

Output: 2,5

Output: 6,4

Output: error

Question 6. Which data type will be used to represent the following data values and why?

a) Number of months in a year

b) Resident of Delhi or not

c) Mobile number

d) Pocket money

e) Volume of a sphere

f) Perimeter of a square

g) Name of the student

h) Address of the student

Question 7. Give the output of the following when num1 = 4, num2 = 3, num3 = 2

a) num1 += num2 + num3

print (num1)

b) num1 = num1 ** (num2 + num3)

c) num1 **= num2 + num3

d) num1 = ‘5’ + ‘5’

print(num1)

e) print(4.00/(2.0+2.0))

f) num1 = 2+9*((3*12)-8)/10

g) num1 = 24 // 4 // 2

h) num1 = float(10)

i) num1 = int(‘3.14’)

j) print(‘Bye’ == ‘BYE’)

k) print(10 != 9 and 20 >= 20)

l) print(10 + 6 * 2 ** 2 != 9//4 -3 and 29

>= 29/9)

m) print(5 % 10 + 10 < 50 and 29 <= 29)

n) print((0 < 6) or (not(10 == 6) and

(10<0)))

Output:1024

Output:27.2

Output:10.0

Output: False

Output:True

Output: True

Question 8. Categorise the following as syntax error, logical error or runtime error:

b) num1 = 25; num2 = 0; num1/num2

a) 25 / 0 :- Runtime Error, because of divisible by zero

b) num1 = 25; num2 = 0; num1/num2 :- Runtime Error, because of divisible by zero

Question 9. A dartboard of radius 10 units and the wall it is hanging on are represented using a two-dimensional coordinate system, with the board’s center at coordinate (0,0). Variables x and y store the x-coordinate and the y-coordinate of a dart that hits the dartboard. Write a Python expression using variables x and y that evaluates to True if the dart hits (is within) the dartboard, and then evaluate the expression for these dart coordinates:

In case you are missed :- Previous Chapter Solution

Question 10. Write a Python program to convert temperature in degree Celsius to degree Fahrenheit. If water boils at 100 degree C and freezes as 0 degree C, use the program to find out what is the boiling point and freezing point of water on the Fahrenheit scale. (Hint: T(°F) = T(°C) × 9/5 + 32)

deffar_conv(t):

x=t*9/5 + 32

print(far_conv(100))

Question 11 . Write a Python program to calculate the amount payable if money has been lent on simple interest. Notes Ch 5.indd 117 08-Apr-19 12:35:13 PM 2020-21 118 Computer Science – Class xi Principal or money lent = P, Rate of interest = R% per annum and Time = T years. Then Simple Interest (SI) = (P x R x T)/ 100. Amount payable = Principal + SI. P, R and T are given as input to the program.

principal=int(input(“P=”))

rate=int(input(“I=”))

time=int(input(“T=”))

defamount_pay(principal,rate,time):

simple_intrest=(principal*rate*time)/100

TOTAL_amount=Print+simple_intrest

returnTOTAL_amount

print(“Total Payble amount”)

print(amount_pay(principal,rate,time))

Question 12. Write a program to calculate in how many days a work will be completed by three persons A, B and C together. A, B, C take x days, y days and z days respectively to do the job alone. The formula to calculate the number of days if they work together is xyz/(xy + yz + xz) days where x, y, and z are given as input to the program.

x=int(input(“x=”))

y=int(input(“Y=”))

z=int(input(“Y=”))

defwork_days(x,y,z):

days=x*y*z/(x*y+y*z+z*x)

return days

print(“Work will complet(in days)”)

print(work_days(x,y,z))

Question 13. Write a program to enter two integers and perform all arithmetic operations on them.

a=int(input(“Enter First Number: “))

b=int(input(“Enter Second Number: “))

defAddtion(a,b):

def subtraction(a,b):

def multiplication(a,b):

def division(a,b):

print(“Addtion of {0} & {1} is : “.format(a,b))

print(Addtion(a,b))

print(“subtraction of {0} & {1} is : “.format(a,b))

print(subtraction(a,b))

print(“multiplicationof {0} & {1} is : “.format(a,b))

print(multiplication(a,b))

print(“division of {0} & {1} is : “.format(a,b))

print(division(a,b))

Question14. Write a program to swap two numbers using a third variable.

first_number=int(input(“Enter First Number: “))

second_number=int(input(“Enter Second Number: “))

def swap(first_number,second_number):

third_variable=first_number

first_number=second_number

second_number=third_variable

returnfirst_number,second_number

print(swap(first_number,second_number))

Question 15.  Write a program to swap two numbers without using a third variable.

first_number,second_number=second_number,first_number

Question 16. Write a program to repeat the string ‘‘GOOD MORNING” n times. Here ‘n’ is an integer entered by the user.

n=int(input(“Enter Number: “))

fori in range(n):

print(“GOOD MORINING “)

Question 17. Write a program to find average of three numbers.

x=int(input(“Enter First Number: “))

y=int(input(“Enter Second Number: “))

z=int(input(“Enter Third Number: “))

def  average(x,y,z):

avg=x+y+z/3

print(“Average : “)

print(average(x,y,z))

Question 18. The volume of a sphere with radius r is 4/3πr3. Write a Python program to find the volume of spheres with radius 7cm, 12cm, 16cm, respectively.

defvolume_sphere(r):

pi=3.1415926535897931

volume=4.0/3.0*pi* r**3

return volume

print(“volume of spheres with radius 7cm”)

print(volume_sphere(7))

print(“volume of spheres with radius 12cm”)

print(volume_sphere(12))

print(“volume of spheres with radius 16cm”)

print(volume_sphere(16))

Question 19. Write a program that asks the user to enter their name and age. Print a message addressed to the user that tells the user the year in which they will turn 100 years old.

fromdatetime import datetime

name = input(‘Name \n’)

age = int(input(‘Age  \n’))

defhundred_year(age):

hundred = int((100-age) + datetime.now().year)

return hundred

x=hundred_year(age)

print (‘Hello %s.  You will turn 100 years old in %s.’ % (name,x))

Question 20. The formula E = mc2 states that the equivalent energy (E) can be calculated as the mass (m) multiplied by the speed of light (c = about 3×108 m/s) squared. Write a program that accepts the mass of an object and determines its energy.

m=int(input(“Enter Mass in Kg: “))

def Einstein(m):

c=299792458

print(“Equivalent energy (E): “)

print(Einstein(m))

Question 21. Presume that a ladder is put upright against a wall. Let variables length and angle store the length of the ladder and the angle that it forms with the ground as it leans against the wall. Write a Python program to compute the height reached by the ladder on the wall for the following values of length and angle:

a)16 feet and 75 degrees

b)20 feet and 0 degrees

c)24 feet and 45 degrees

d)24 feet and 80 degrees

import math

defheight_reched(length,degrees):

radian=math.radians(degrees)

sin=math.sin(radian)

height=round(length*sin,2)

return height

print(” height reached by the ladder on the wall for the  length is 16 feet and 75 degrees “)

print(height_reched(16,75))

print(” height reached by the ladder on the wall for the  length is 20 feet and 0 degrees “)

print(height_reched(20,0))

print(” height reached by the ladder on the wall for the  length is 24 feet and 45 degrees “)

print(height_reched(24,45))

print(” height reached by the ladder on the wall for the  length is 24 feet and 80 degrees “)

print(height_reched(24,80))

In case you are missed :- Next Chapter Solution

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Save my name, email, and website in this browser for the next time I comment.

We have a strong team of experienced Teachers who are here to solve all your exam preparation doubts

As a health-conscious person, you noticed an advertisement in the newspaper on yoga classes in your neighbourhood. write a letter to the organizers enquiring about the duration of the course and other relevant details, madam rides the bus extra questions and answers english first flight chapter 9, ncert solutions class 10 science chapter 10 light reflection and refraction.

RS Aggarwal Class 8 Math First Chapter Exercise 1a

RS Aggarwal Class 8 Math First Chapter Rational Numbers Exercise 1A Solution

Sign in to your account

Username or Email Address

Remember Me

Write the corresponding Python assignment statements: Assign the strings Mohandas, Karamchand, and Gandhi to variables first, middle and last.

First, middle, last = "mohandas", "karamchand", "gandhi".

IMAGES

  1. #5 Variables, Assignment statements in Python || Python Course 2020

    write the corresponding python assignment statements

  2. TYPES OF ASSIGNMENT STATEMENTS IN PYTHON

    write the corresponding python assignment statements

  3. (D) Write the corresponding Python assignment statements: (3) a) Assign

    write the corresponding python assignment statements

  4. Introduction into Python Statements: Assignment, Conditional Examples

    write the corresponding python assignment statements

  5. PPT

    write the corresponding python assignment statements

  6. Types of Statements in Python

    write the corresponding python assignment statements

VIDEO

  1. Assignment

  2. Python

  3. Operators & Conditional Statements

  4. IF statements in python. How to write if statements in PYTHON

  5. Video12: Understanding Grading Functions

  6. Jens Nie: Accelerating Python Code

COMMENTS

  1. Write the corresponding Python assignment statements:a Assign 10 to

    Q. Write logical expressions corresponding to the following statements in Python and evaluate the expressions (assuming variables num1, num2, num3, first, middle, last are already having meaningful values): a) The sum of 20 and -10 is less than 12. b) num3 is not more than 24 c) 6.75 is between the values of integers num1 and num2. d) The string 'middle' is larger than the string ...

  2. Python's Assignment Operator: Write Robust Assignments

    Here, variable represents a generic Python variable, while expression represents any Python object that you can provide as a concrete value—also known as a literal—or an expression that evaluates to a value. To execute an assignment statement like the above, Python runs the following steps: Evaluate the right-hand expression to produce a concrete value or object.

  3. Write the corresponding Python assignment statements: Assign 10 to

    Q. Write the corresponding Python assignment statements: (a) Assign 10 to variable length and 20 to variable breadth. (b) Assign the average of values of variables length and breadth to a variable sum. (c) Assign a list containing strings 'Paper', 'Gel Pen', and 'Eraser' to a variable stationery.

  4. Different Forms of Assignment Statements in Python

    Multiple- target assignment: x = y = 75. print(x, y) In this form, Python assigns a reference to the same object (the object which is rightmost) to all the target on the left. OUTPUT. 75 75. 7. Augmented assignment : The augmented assignment is a shorthand assignment that combines an expression and an assignment.

  5. NCERT Solution Getting Started with Python Class 11 Chapter 5

    True. Identifier can not be a Keyword. Getting Started with Python Class 11 Solution. Q2. Write the corresponding Python assignment statements: a) Assign 10 to variable length and 20 to variable breadth. b) Assign the average of values of variables length and breadth to a variable sum. c) Assign a list containing strings 'Paper', 'Gel Pen ...

  6. NCERT Solutions for Class 11 Science Computer science ...

    Question 2: Write the corresponding Python assignment statements: a) Assign 10 to variable length and 20 to variable breadth. b) Assign the average of values of variables length and breadth to a variable sum c) Assign a list containing strings 'Paper', 'Gel Pen', and 'Eraser' to a variable stationery.

  7. NCERT Solutions Class 11 Computer Science Chapter 5 Getting Started

    Write the corresponding Python assignment statements: a) Assign 10 to variable length and 20 to variable breadth. b) Assign the average of values of variables length and breadth to a variable sum. c) Assign a list containing strings 'Paper', 'Gel Pen', and 'Eraser' to a variable stationery.

  8. Write the corresponding Python assignment statements:

    Write the corresponding Python assignment statements: a) Assign 10 to variable length and 20 to variable breadth. b) Assign the average of values of variables length and breadth to a variable sum. c) Assign a list containing strings 'Paper', 'Gel Pen', and 'Eraser' to a variable stationery.

  9. Write the corresponding Python assignment statements:

    Write a Python program to convert temperature indegree Celsius to degree Fahrenheit. If water boils at 1 0 0 degree C and freezes as 0 degree C, use the program to find out what is the boiling point and freezing point of water on the Fahrenheit scale. (Hint: T (∘ F) = T (∘ C) × 9 / 5 + 3 2)

  10. Write the corresponding Python assignment statements:

    Write the corresponding Python assignment statements: Assign a list containing strings Paper, Gel Pen, and Eraser to a variable ... III and IV. You have to consider the two statements to be true even if they seem to be at variance from commonly known facts. You have to decide which of the given conclusions, if any, follow from the given ...

  11. Write the corresponding Python assignment statements:

    Click here👆to get an answer to your question ️ Write the corresponding Python assignment statements:Assign the average of values of variables length and breadth to a variable sum.

  12. Write the corresponding Python assignment statements a Assign 6

    The required statement to assign values is provided below: a, b = 6, 7 . In Python, the values of two variables can be assigned in a single line using the comma between the variables and their values after the assignment operator as a, b = 6, 7. b. The required statement to assign values is provided below: c = (a + b) / 2

  13. Write the corresponding Python assignment statements:

    Find step-by-step Computer science solutions and your answer to the following textbook question: Write the corresponding Python assignment statements: (a) Assign 6 to variable a and 7 to variable b. (b) Assign to variable c the average of variables a and b. (c) Assign to variable inventory the list containing strings 'paper', 'staples', and 'pencils'.

  14. Solved Write Python expressions corresponding to these

    Write Python expressions corresponding to these statements: (f) '+-+++--+-+++--+-+++--+-+++--+-+++--' Try to make your string expressions as succinct as you can. 2.14 Start by running, in the shell, the following assignment statement: >>> s = 'abcdefghijklmnopqrstuvwxyz' Now write expressions using string s and the indexing operator that evaluate to 'a', 'c', 'z ...

  15. Best way to do conditional assignment in python

    "a = 0 or None" Well of course the console won't print anything, you're assigning the result of 0 or None to a, and variables with None assigned to them don't automatically display None when shown in the console. You have to specifically use repr, str, or print.Or something like that.

  16. Write the corresponding Python assignment statement: Assign the

    Write the corresponding Python assignment statement: Assign the strings 'Mohandas', 'Karamchand', and 'Gandhi' to variables first, middle and last. Write a logical expression corresponding to the following statement in Python and evaluate the expressions (assuming variables num1, num2, num3, first, middle, and last are already ...

  17. Write the corresponding Python assignment statement: Assign a list

    Write the corresponding Python assignment statement: Assign the average of values of the variable's length and breadth to a variable sum. Write a program to swap two numbers using a third variable. Write a program to swap two numbers without using a third variable. Give the output of the following when num1 = 4, num2 = 3, num3 = 2. num1 = float(10)

  18. Write the corresponding Python assignment statements:

    Click here:point_up_2:to get an answer to your question :writing_hand:write the corresponding python assignmentstatementsassign the strings mohandas karamchand andgandhi to variables first middle and

  19. Write the corresponding Python assignment statements: a) Assign 10 to

    Write the corresponding Python assignment statements: a) Assign 10 to variable length and 20 to variable breadth. b) Assign the average of values of variables length and breadth to a variable sum. e) Assign the concatenated value of string variables first, middle and last to variable fullname.

  20. PDF Programming Principles in Python (CSCI 503/490)

    It's often only necessary to care about the general kind of data you're dealing with, whether floating point, complex, integer, boolean, string, or general Python object. When you need more control over how data are stored in memory and on disk, Type. Type code. Description.

  21. Q1. Write the corresponding Python assignment statements: a) Assign 10

    Write the corresponding Python assignment statements: a) Assign 10 to variable length and 20 to variable breadth. b) Assign the average of values of variables length and breadth to a variable sum. c) Assign a list containing strings 'Paper', 'Gel Pen', and 'Eraser' to a variable stationery.

  22. Write the corresponding Python assignment statement: Assign the average

    Write the corresponding Python assignment statement: Assign a list containing strings 'Paper', 'Gel Pen', and 'Eraser' to variable stationery. Write a program to swap two numbers using a third variable. Write a program to swap two numbers without using a third variable. Give the output of the following when num1 = 4, num2 = 3, num3 = 2.

  23. Write the corresponding Python assignment statements:

    Write the corresponding Python assignment statements: →Assign 20 to variables x, y and z in a single statement… Get the answers you need, now! ponplanivel ponplanivel ... Write statement in python to assign 100 in variable z2. Advertisement Advertisement New questions in Computer Science.

  24. Q1. Write the corresponding Python assignment statements: a) Assign 10

    Python-Python is a simple programming language. It has been created by Guido van Rossum and launched in 1991. Its features make it easy to understand and this language is used a lot in the big companies and industries. Given question: Write the corresponding Python assignment statements: a) Assign 10 to variable length and 20 to variable breadth.