Assignment Operators in Python

Assignment Operators in Python


Assignment Operator combines the effect of arithmetic and assignment operator


Symbol
Description
Example
=
Assigned values from right side operands to left variable

>>>x=12*

>>>y="greetings"

+=
added and assign back the result to left operand
>>>x+=2
-=
subtracted and assign back the result to left operand
x-=2
*=
multiplied and assign back the result to left operand
x*=2
/=
divided and assign back the result to left operand
x/=2
%=
taken modulus using two operands and assign the result to left operand
x%=2
**=
performed exponential (power) calculation on operators and assign value to the left operand
x**=2
//=
performed floor division on operators and assign value to the left operand
x / /= 2


Example: To test Assignment Operators:

#Demo Program to test Assignment Operators
x=int (input("Type a Value for X : "))
print ("X = ",x)
print ("The x is =",x)
x+=20
print ("The x += 20 is =",x)
x-=5
print ("The x -= 5 is = ",x)
x*=5
print ("The x *= 5 is = ",x)
x/=2
print ("The x /= 2 is = ",x)
x%=3
print ("The x %= 3 is = ",x)
x**=2
print ("The x **= 2 is = ",x)
x//=3
print ("The x //= 3 is = ",x)
#Program End

Output:

Type a Value for X : 10

X = 10

The x is = 10

The x += 20 is = 30

The x -= 5 is = 25

The x *= 5 is = 125

The x /= 2 is = 62.5

The x %= 3 is = 2.5

The x **= 2 is = 6.25

The x //= 3 is = 2.0


Qus. 1 : Which translator is used to convert assembly language into machine language?

  1. Compiler
  2. Interpreter
  3. Assembler
  4. None of these
Qus. 2 : which one is an Assignment Operator

  1. #
  2. =
  3. /
  4. &
Qus. 3 : Which of the following is an invalid statement in python.

  1. abc=2,00,000
  2. a,b,c=200,300,400
  3. a_b_c= 2,00,000
  4. abc=200 300 400
Qus. 4 : Which of the following will give error ?

  1. a=b=c=1
  2. a,b,c=1
  3. a, b, c = 1, "python", 1.5
  4. None of the above
Qus. 5 : Which statement can be use to swap the values of an and b

  1. a=b,b=a
  2. a,b=b,a
  3. a=b;b=a
  4. a=b and b=a
Qus. 6 : Which expression is equivalent to A=A*8

  1. A*A=8
  2. A*=8
  3. A*8=A
  4. A=*8

Programs

python Program to obtain temperature in Celsius and convert it into Fahrenheit

View Solution


pythoon program to read todays date only date Part from user Then display how many days are left in the current month

View Solution


python program to print the area of circle when radius of the circle is given by user

View Solution


python program to print the volume of a cylinder when radius and height of the cylinder is given by user

View Solution


python program that asks your height in centimeters and converts it into foot and inches

View Solution


python program accept three side of triangle and find area of a triangle

View Solution


python program to input principle amount,rate time and calculate simple interes

View Solution


python program to read a number in n and prints n2 n3 n4

View Solution


python program to calculate compound simple interest after taking the principle rate and time

View Solution


python program to take two numbers and check that the first number is fully divisible by second number or not

View Solution


python program which take value of x y z from the user and calculate the equation

View Solution


python program to take the temperatures of all 7 days of the week and displays the average temperature of that week

View Solution


python program to check the given year is leap year or not

View Solution


python program that searches for prime numbers from 15 through 25

View Solution


python program to test if given number is prime or not

View Solution


python program to compute the result when two numbers and one operator is given by user

View Solution


python program to calculate the roots of a given quadratic equation.

View Solution


python program to input a digit and print it in words

View Solution


python program to check whether square root of a given number is prime or not

View Solution


python program to print first n odd numbers in descending order.

View Solution


python program to find the average of the list of the numbers entered through keyboard

View Solution


python program to find the largest number from the list of the numbers entered through keyboard

View Solution


python program to find the sum of n natural numbers

View Solution


python program to find the sum of first n even numbers

View Solution


python program to find the sum of first n odd numbers.

View Solution


python program to generate a list of elements of Fibonacci Series

View Solution


python program to find simple interest based upon number of years

View Solution


python program to input any choice and to implement the following

View Solution


python program to input any number and to print all natural numbers up to given number

View Solution


python program to input any number and to find sum of all natural numbers up to given number

View Solution


python program to input any number and to find reverse of that number

View Solution


python program to input any string and count number of uppercase and lowercase letters

View Solution


python program to obtain three numbers and print their sum

View Solution


Python program to obtain length and breath of a rectangle and calculate its area

View Solution


python program to calculate body mass index of a person

View Solution


python program to input a number and print its cube

View Solution


python program to input two number and swap them

View Solution


python program to input three number and swap 3 numbers

View Solution


python program to read 3 numbers in 3variables and swap first two variables with the sums of first and second

View Solution


python program to input a single digit and print a 3 digit number

View Solution


python program to accept a integer number and find its sum of digit

View Solution


python program to count the number of digits in given number

View Solution


python program to find the factorial value of given number

View Solution


python program to print factor of given number

View Solution


python program to check given number is composite number or not

View Solution


python program to find the largest digit of a given number

View Solution


python program to find the smallest digit of a given number

View Solution


python program to print table of entered number

View Solution


python program to calculate the compound interest

View Solution


python program to find sale price of an item with given price and discount

View Solution


python program to calculate the sum of odd numbers divisible by 5 from the range 1 to 100

View Solution


Python Program to Calculate the Area of a Triangle

View Solution


python program for addition of two times in hour and minute format

View Solution


python program for addition of two times in hour minute and second format

View Solution


python program to check number is positive negative or zero

View Solution


python program to check number is even or odd

View Solution


python program to check where is profit or loss

View Solution


python program to check number is buzz number or not

View Solution


python program to input assets liabilities and capital then check accounting equation means balanced or not

View Solution


python program to input total debt and total assets and calculate total debt to total assets ratio and check whether major funded by assets or equity

View Solution


python program to calculate debt to equity check whether it is risky scenario for investor or not

View Solution


python program to find the difference between greatest and smallest digits presents in the number

View Solution


python program to print the frequency of digits present in given number

View Solution


python program to print Floyds triangle

View Solution


python program to check whether given number is Armstrong or not

View Solution


python program to find all prime numbers up to given number

View Solution


python program to convert decimal number to binary

View Solution


Python program to convert binary to decimal

View Solution


python program to print quotient

View Solution


Python program to calculate simple interest

View Solution


Python program to calculate area and perimeter of a parallelogram

View Solution


Python program demonstrating working with power operator

View Solution


Python program of division operator

View Solution


Python program of modulus

View Solution


Python program convert dollars in Rupee

View Solution


Python program to convert kilometers to miles

View Solution


Python program to convert the distance in feet to inches yards and miles

View Solution


Python credit card program

View Solution


Python program to print absolute value of number provided by the user

View Solution


Python program to check divisibility of a number

View Solution


Python program to print the largest number

View Solution


Python program to display menu to calculate area of square or rectangle

View Solution


Python program to print larger number using swap

View Solution


Python program to calculate electricity bill

View Solution


Python program to input three number and print in ascending order

View Solution


Python program to check character is alphabetic character or not

View Solution


Python program to print letters of word

View Solution


Python program to print ASCII code for entered message

View Solution


Python program to print first ten mersenne numbers

View Solution


python program to obtain x y z from user and calculate expression

View Solution


python program that reads a number of seconds and prints it in form mins and seconds

View Solution


python program to take year as input and check if it is a leap year or not

View Solution


python program to take two numbers and print if the first number is fully divisible by second number or not

View Solution


python program to take a 2 digit number and then print the reversed number

View Solution


python program to take a 3 digit number and then print the reversed number

View Solution


python program to take two inputs for day month and then calculate which day of the year

View Solution


python program that asks a user for a number of years and then prints out the number of days hours minutes and seconds

View Solution


python program that inputs an age and print age after 10 years

View Solution


python program to find a side of a right angled triangle whose two sides and an angle is given

View Solution


python program to calculate the radius of a sphere whose area is given

View Solution


python program to calculate the area of an equilateral triangle

View Solution


python program to input the radius of a sphere and calculate its volume

View Solution


python program to calculate amount payable after simple interest

View Solution


python program to input length of three sides of a triangle Then check if these sides will form a triangle or not

View Solution


python program to input 3 sides of a triangle and print whether it is an equilateral scalene or isosceles triangle

View Solution


python program to Print numbers from 11 to N When the number is a multiple of 3 print Tipsy when it is a multiple of 7 print Topsy

View Solution


python program to input N numbers and then print the second largest number

View Solution


python program to input list of numbers and find those which are palindromes

View Solution


python program to place and the most significant digit of number

View Solution


Python program to print every integer between 1 and n divisible by m Also report whether the number that is divisible by m is even or odd

View Solution


python program to find the LCM of two input numbers

View Solution


python program to find GCD of 2 number

View Solution


python program to check number is perfect number or not

View Solution


python program to check number is special or not

View Solution


python program to print first n perfect numbers

View Solution


Python program using if Elif else statement to find the number of days present in a month

View Solution


python program to print all buzz numbers between 1 to n

View Solution


Python program to input 3 numbers and check all are same or not

View Solution


python program to input 3 numbers from user and check these are unique numbers are not

View Solution


python program to input 2 integer number and check where they are same of different number

View Solution


Python function which takes list of integers as input and finds the followings

View Solution


Python program to print all the prime numbers in the given range

View Solution


Python program to print the sum of series

View Solution


python program to input the time in second and convert into hours minute and seconds

View Solution


python program to obtain the marks in computer of some student and find mean median and mode

View Solution


Write a Python code to calculate and display the value of Sine 45° and Cosine 30°

View Solution


python program to input three unequal numbers and display the greatest and the smallest number

View Solution


python program to accept marks of English math and science and display the appropriate stream allotted to the candidate

View Solution


python program to calculate income tax based on condition

View Solution


python program to calculate volume of cuboid cylinder and cone based on user choice

View Solution


python program to display the first ten terms of the following series 2 5 10 17

View Solution


python program to find the sum of first ten terms of the series

View Solution


python program to find the smallest digit of the input number

View Solution


python program to check whether it is a prime number or not If it is not a prime then display the next number that is prime

View Solution


python program to accept the Base and Perpendicular and find the Hypotenuse

View Solution


python program to accept three side of triangle and find its area by using Herons Formula

View Solution


python program to accept side of Equilateral Triangle and find its area

View Solution


Python program to check whether dart hit inside board or outside

View Solution


CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad