Python Basics

Day 1

  1. Sum using the + operator

  2. Multiply

  3. divide

  4. subtract

  5. Complex number where iota is denoted with j

  6. Different ways of declaring variables.

  7. a,b,c,d = 1,2,3,4

  8. special characters in variables @,%,-,+

  9. Can use an underscore for it though. _a is a valid variable name

  10. Data types:

    a. int

    b. float

    c. boolean or bool

    d.string and various ways of declaring a string, concatenation a1 + a2

  11. Type casting an int to string

  12. Type casting from string to int is not valid

  13. Taking input from the user.

  14. Typecasting the input() function

  15. Indexing in a string, negative indexing

  16. Slicing in a string

  17. Jum/Step in slicing

  18. Reverse of a string

  19. Item reassignment - mutability and immutability

Questions

  1. Declare two variables, x and y, and assign them integer values. Swap the values of these variables without using any temporary variable.

  2. Create a program that calculates the area of a rectangle. Take the length and width as inputs from the user and store them in variables. Calculate and display the area.

  3. Write a Python program that converts temperatures from Celsius to Fahrenheit. Take the temperature in Celsius as input, store it in a variable, convert it to Fahrenheit, and display the result.

  4. Given a string, reverse the order of characters using string slicing and print the reversed string.