100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Complete Python Programming from Basics to Advanced Concepts $7.49   Add to cart

Class notes

Complete Python Programming from Basics to Advanced Concepts

 5 views  0 purchase
  • Course
  • Institution

All the notes gives a very good understanding of the basic and the advanced concepts in python programming, this also covers the area of OOP.

Preview 2 out of 7  pages

  • June 11, 2023
  • 7
  • 2022/2023
  • Class notes
  • Mr.saman
  • All classes
  • Unknown
avatar-seller
6/10/23, 2:07 PM Variables and Data Types.ipynb - Colaboratory



Variables and Data Types 🔥


Variables 🚀

Variable are containers for storing data values.



Creating a Variable
A variable is created the moment you first assign a value to it.


x = 5
print(x)

5


y = "Nazhim"
print(y)

Nazhim


z = 2.56
print(z)

2.56


a = True
b = False

print(a)
print(b)

True
False


Variables do not need to be declared with any particular type, and can even change type after they have been set.


# Firstly the variable 'number' is stores 5
number = 5
print(number)

# Now, we update the content of the variable 'number'
number = "Kevin"
print(number)


5
Kevin



What are comments ?
Comments can be used to explain Python code.

Comments can be used to make the code more readable.

Comments can be used to prevent execution when testing code.

Comments starts with a #

Comments have no affect with the program code, its only used to give the user some meaning of the code


Single Line Comment

# This is a single line comment
https://colab.research.google.com/drive/1TYB6-QkORCNTdH4X2b8C8z0eJDP6xxRF 1/7

, 6/10/23, 2:07 PM Variables and Data Types.ipynb - Colaboratory
g



Multi Line Comment

# This
# is
# a
# multi
# line
# comment



Casting
If you want to specify the data type of a variable, this can be done with casting.

You can get the data type of a variable with the type() function.


x = str(3) # x will be '3'
y = int(3) # y will be 3
z = float(3) # z will be 3.0

print(x, y, z)
print(type(x), type(y), type(z))

3 3 3.0
<class 'str'> <class 'int'> <class 'float'>



Single or Double Quotes in Strings

x = "Nazhim"
y = 'Nazhim'

print(x)
print(y)

Nazhim
Nazhim



Case Sensitive
Variable names are case-sensitive


a = 4
A = "Sally"

# A will not overwrite a

print(a, A)

4 Sally



Quick Code Summary Example of what Variables and Comments

name = "Nazhim" # variable 'name' stores the String 'Nazhim'
age = 25 # variable 'age' stores the integer number 25
height = 6.1 # variable 'height' stores the decimal value 6.1



# Now let's print out the results of the variables
print("My name is " + name) # we don't cast the name variable because its already in the same type which is String
print("I am " + str(age) + " years old")
print("I am " + str(height) + " feet tall")


My name is Nazhim
I am 25 years old
I am 6.1 feet tall
https://colab.research.google.com/drive/1TYB6-QkORCNTdH4X2b8C8z0eJDP6xxRF 2/7

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller nazhimkalam. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $7.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

83100 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$7.49
  • (0)
  Add to cart