0% found this document useful (0 votes)
53 views

Siddhesh

This document discusses important Python codes covered in Lecture 1, including the IPO cycle, variables, arithmetic operators, string operations, data types, type casting, user input, and taking numbers as input to add them. Key codes shown include defining variables, performing arithmetic, concatenating and replicating strings, using print() to output data, and casting between data types using functions like int(), float(), and str().
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Siddhesh

This document discusses important Python codes covered in Lecture 1, including the IPO cycle, variables, arithmetic operators, string operations, data types, type casting, user input, and taking numbers as input to add them. Key codes shown include defining variables, performing arithmetic, concatenating and replicating strings, using print() to output data, and casting between data types using functions like int(), float(), and str().
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Bakliwal Tutorials

------------------------------------------------------------------------------------------------------------------------------------------
---
Some Important Codes Discussed in Lecture 1

#IPO cycle
#Input Process Output
#data

#container / instances / variables


x = 35
y = 8
#Arithmetic Operators
sum = x + y
diff = x - y
mul = x * y
div = x / y

#print () to output data in the console


# print (sum)
# print (diff)
# print (mul)
# print (div)
# print (sum, diff, mul, div)

quo = x // y # quotient
rem = x % y # remainder

# print (quo)
# print (rem)

#Text (String) data in python


# print ("This is a text.")
firstName = "Raghav"
lastName = "Mishra"
#concatenation (joining) of strings
fullName = firstName + " " + lastName
# print (fullName)
#replication of strings
repeatName = (fullName + " ") * 5
# print (repeatName)

#decimal numbers (floating point numbers)


x = 4.3
y = 2.6
# print (x + y)
Bakliwal Tutorials
------------------------------------------------------------------------------------------------------------------------------------------
---

# n -> newline command


# \ -> escape sequence
# print ("My name is Raghav Mishra.\nI work at Bakliwal
Tutorials.\nIt's based in Pune.\n\n")

# t -> tabline command to indent output in tabular form


# print ("Fruits\t\tQuantity")
# print ("Apple\t\t6")
# print ("Banana\t\t24")
# print ("Orange\t\t12")
# print ("Peach\t\t6")
# print ("Leechi\t\t60")

"""
#Type casting of data using int (), float () & str () function
x = "40"
y = "30"
print (x + y)
# int () converts a numeric string into an integer value
print (int (x) + int (y))

a = 50
b = 30
print (a + b)
# str () converts an integer value into a numeric string
print (str (a) + str (b))

num1 = "50.34"
num2 = "2.1"
print (num1 + num2)
#float () converts a string into decimal value
print (float (num1) + float (num2))
"""

"""
# tAKING USER INPUT FROM THE CONSOLE USING THE input () function
firstName = input ("Enter your first name: ")
lastName = input ("Enter your last name: ")
fullName = firstName + " " + lastName
print ("Your full name is " + fullName + ".")
"""

#Take two numbers as input from the user and add them
# input () function takes input as a string
Bakliwal Tutorials
------------------------------------------------------------------------------------------------------------------------------------------
---
num1 = int (input ("Enter the first number: "))
num2 = int (input ("Enter the second number: "))
sum = num1 + num2
print (sum)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy