ICP 1 - Saiaishwaryapuppala/CSEE5590_python_Icp GitHub Wiki
Python and Deep Learning: Special Topics
Rajeshwari Sai Aishwarya Puppala
Student ID: 16298162
In class programming:1
Objectives
1.State differences between Python 2 and Python 3 version.
2.Input the string “Python” as a list of characters from the console, delete at least 2 characters, reverse the resultant string and print it.
-
Sample input:python
-
Sample output:ntyp
Take two numbers from the user and perform arithmetic operations on them.
3.Write a program that accepts a sentence and replace each occurrence of ‘python’ with ‘pythons’ without using regex.
-
Sample input:I love playing with python
-
Sample output:I love playing with pythons
Differences between python 2 and 3
Python2
-
Started in mid 2010
-
Integer division 5/2=2
-
Print statement ex: print "hello"
-
It uses xrange and range functions
-
Here raw_input returns a string and input() tries to run the input as a python expression
Python3
-
Started in early 2014
-
Integer division 5/2=2.5
-
Print statement ex: print ("hello")
-
It has no xrange function
-
Here input() returns a string always
Deleting at least 2 chars and Reverse the string
CODE
- Reverse string function is called
- Input is taken from the console
- last and last but second chars are removed (remove function is called)
- Reverse the string by calling reverse function
Output
Arithmetic Operations
Code
- Take 2 numbers from the console
- Call the arithmetic operation functions i.e add, subtract, multiply, divide
Output:
Replacing python with pythons
Code:
- Take the string from the console
- convert into lower case
- Replace the "python" with "pythons" by using replace method
Output: