PDA Assignments
  • Python For Data Analytics
    • 1.Python
      • 1.Python Documents
        • 1.Data Types
        • 2.Variables In Python
        • 3.Operators In Python
        • 4.User Input In Python
        • 5.TypeCasting In Python
        • 6.Strings In Python
        • 7.Conditional Statements In Python
        • 8.Branching using Conditional Statements and Loops in Python
        • 9.Lists In Python
        • 10.Sets In Python
        • 11.Tuples In Python
        • 12.Dictionary In Python
        • 13.Functions In Python
        • 14.File Handling In Python
        • 15.Numerical Computing with Python and Numpy
      • 2.Python Assignments
        • Data Type & Variables
        • Operators Assignment
        • User Input & Type Casting
        • Functions- Basic Assignments
        • String Assignments
          • String CheatSheet
        • Conditional Statements Assignments
        • Loops Assignments
        • List Assignments
          • List Cheatsheet
        • Set Assignments
          • Sets Cheatsheet
        • Dictionary Assignments
          • Dictionary Cheatsheet
        • Function Assignments
        • Functions used in Python
      • 3.Python Projects
        • Employee Management System
        • Hamming distance
        • Webscraping With Python
          • Introduction To Web Scraping
          • Importing Necessary Libraries
          • Basic Introduction To HTML
          • Introduction To BeautifulSoup
          • Flipkart Web Scraping
            • Scraping Step By Step
        • Retail Sales Analysis
        • Guess the Word Game
        • Data Collection Through APIs
        • To-Do List Manager
        • Atm-functionalities(nested if)
        • Distribution of Cards(List & Nested for)
        • Guess the Number Game
      • 4.Python + SQL Projects
        • Bookstore Management System
    • 2.Data Analytics
      • 1.Pandas
        • 1.Pandas Documents
          • 1.Introduction To Pandas
          • Reading and Loading Different Data
          • 2.Indexing and Slicing In Pandas
          • 3.Joining In Pandas
          • 4.Missing Values In Pandas
          • 5.Outliers In Pandas
          • 6.Aggregating Data
          • 7.DateTime In Pandas
          • 8.Validation In Pandas
          • 9.Fetching Data From SQL
          • 10. Automation In Pandas
          • 11.Matplotlib - Data Visualization
          • 12. Seaborn - Data Visualization
          • 13. Required Files
        • 3.Pandas Projects
          • Retail Sales Analysis
            • Retail Sales Step By Step
          • IMDB - Dataset Analysis - Basic
        • 2. Pandas Assignments
          • 1. Reading and Loading the Data
          • 2. Data frame Functions and Properties
          • 3. Series - Basic Operations
          • 4. Filtering in Pandas
          • 5. Advance Filtering
          • 6. Aggregate Functions & Groupby
          • 7. Pivot Tables
          • 8. Datetime
          • 9. String Functions
Powered by GitBook
On this page
  1. Python For Data Analytics
  2. 1.Python
  3. 2.Python Assignments

Operators Assignment

  1. The Output of a = 2+3-4/2**2 and also tell its type?

    1. 4 and int

    2. 4.0 and float

    3. 1.0 and float

    4. 5 and int

Solution

Answer : option 2

2. The output of the following python code snippet print(type(4/2)) print(type(4//2))

  1. float and float

  2. float and int

  3. int and float

  4. int and int

Solution

Answer: option 2

  1. What will be the output of the following python code snippet a= 12 print(type(a)) a=’12345’ print(type(a))

a. Int and str b. Int and int c. str and int d. str and str

Solution

Answer: option a

  1. In which manner are operators with the same precedence evaluated?

a. Left to right b. Right to left c. Can’t say d. None of the Above Mentioned

Solution

Answer: option a

  1. Output of a = 2*3/4**1==2.00

a. 1.5 b. 2 c. True d. False

Solution

Answer: option d

  1. Output of the following print(100>2 and 100 > 30)

a. True b. False c. 100 d. 30

Solution

Answer: option a

  1. What will be the output of the following code print(True or True and False)

a. True b. False

Solution

Answer : a because and has higher precedence over or

  1. What will be the precedence of

a. Not b. And c. Or

a. Abc b. Bac c. Bca d. Cab

Solution

Answer: a

  1. The Output of the following 2/2*3**2<=10

a. True b. False c. 9 d. 10

Solution

Answer : a

  1. type(22%3) = ?

a. Int b. Str c. Float d. Can’t say

Solution

Answer: a

  1. Which will give an error?

a. A++ b. ++a c. A += 1 d. Both A and B

Solution

Answer: d

  1. Suppose, there are 5 rupees in your pocket.

  • I am giving you 17 Rs. How many rupees do you have now?

  • Now I am giving you 39 Rs. How many rupees do you have now?

  • Now I am taking 23 Rs. back. How many rupees do you have now?

  • Again I am giving you 932 Rs. How many rupees do you have now?

Solution
a=5
a=a+17              # I am giving you 17 Rs.
print(a)            # How many rupees do you have now?

a=a+39      # I am giving you 39 Rs.
print(a)    # How many rupees do you have now?

a=a-23      # I am taking 23 Rs. back.
print(a)    # How many rupees do you have now?

a=a+932     # I am giving you 932 Rs.
print(a)    # How many rupees do you have now?
  1. Calculate the value of ( a ) in the expression: a =( 5 + 3 - 2 / 2 ).

Solution

7.0

  1. Calculate the value of ( b ) in the expression: b = ((8 - 2) * 3 / 2 )

Solution

9.0

  1. Calculate the value of ( c ) in the expression: c =( 10 / 2 + 3 * 4 )

Solution

17.0

  1. Calculate the value of ( d ) in the expression: d =( 7 + 3 * (2 ** 2) - 5 )

Solution

14

  1. Calculate the value of ( e ) in the expression: e =( (6 / 3) + (8 - 4) )

Solution

6.0

  1. Calculate the value of ( f ) in the expression: f = (5 * (3 + 2) - 8 / 4 )

Solution

23.0

  1. Calculate the value of ( g ) in the expression: g =( 12 / 4 + 7 - 3 * 2 )

Solution

4.0

  1. Calculate the value of ( h ) in the expression: h = (9 - 3 + 4 * (2 ** 2) )

Solution

22

  1. Suppose, you have 150 rupees.

Solution
# Initial amount
rupees = 150

# Spending amounts
rupees -= 45  # spend on meal
print(rupees)
rupees -= 32  # spend on movie ticket
print(rupees)
rupees -= 18  # spend on snacks
print(rupees)
rupees -= 25  # spend on transportation


# Final amount
print(rupees)
  1. You have 200 rupees.

Solution
# Initial amount
amount = 200

# Step 1: You buy a book for 60 rupees
amount -= 60
print('Money left:',amount)

# Step 2: You receive 30 rupees from a friend
amount += 30
print('Money left:',amount)

# Step 3: You donate 10% of your current money to charity
charity_amount= amount * 10/100
amount -=charity_amount
print('Money left:',amount)

# Step 4: You find 5 rupees in your pocket
amount += 5
print('Money left:',amount)

# Step 5: You split the remaining amount equally with a friend
amount /= 2
print('Money left:',amount)

# Step 6: Your amount is tripled as you win a prize
amount *= 3
print('Money left:',amount)

# step 7: price of rose is 50 but increased by 10 rupees.

rose_price=50
rose_price+=10
print('rose price paid:',rose_price)
amount-= rose_price
print('Money left:',amount)

PreviousData Type & VariablesNextUser Input & Type Casting

Last updated 9 months ago