Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

Kartik Jatwani

1/18/FET/BBT/003
Program 1.

Aim: Demonstrate the installation of Python and its Editor, various package installation Process.

Python can be installed directly from the browser, windows store etc.

Multiple editors like atom etc. can be used for python.

Installing python is easy.

What Your Options Are

As mentioned earlier, there are three ways to install the official Python distribution on Windows:

1. Microsoft Store package: The most straightforward installation method on Windows involves installing from
the Microsoft Store app. This is recommended for beginner Python users looking for an easy-to-set-up
interactive experience.
2. Full Installer: This approach involves downloading Python directly from the Python.org website. This is
recommended for intermediate and advanced developers who need more control during the setup process.
3. Windows Subsystem for Linux (WSL): The WSL allows you to run a Linux environment directly in
Windows. You can learn how to enable the WSL by reading the Windows Subsystem for Linux Installation
Guide for Windows 10.

In this section, we’ll focus on only the first two options, which are the most popular installation methods in a
Windows environment.

If you want to install in the WSL, then you can read the Linux section of this tutorial after you’ve installed the Linux
distribution of your choice.

Note: You can also complete the installation on Windows using alternative distributions, such as Anaconda, but this
tutorial covers only official distributions.

Anaconda is a popular platform for doing scientific computing and data science with Python. To learn how to install
Anaconda on Windows, check out Setting Up Python for Machine Learning on Windows.
The two official Python installers for Windows aren’t identical. The Microsoft Store package has some important
limitations.

Limitations of the Microsoft Store Package

The official Python documentation has this to say about the Microsoft Store package:

The key takeaway here is that the Microsoft Store package is “intended mainly for interactive use.” That is, the
Microsoft Store package is designed to be used by students and people learning to use Python for the first time.

In addition to targeting beginning Pythonistas, the Microsoft Store package has limitations that make it ill-suited for a
professional development environment. In particular, it does not have full write access to shared locations such
as TEMP or the registry.

Windows Installer Recommendations

If you’re new to Python and focused primarily on learning the language rather than building professional software,
then you should install from the Microsoft Store package. This offers the shortest and easiest path to getting started
with minimal hassle.

Kartik Jatwani
1/18/FET/BBT/003
On the other hand, if you’re an experienced developer looking to develop professional software in a Windows
environment, then the official Python.org installer is the right choice. Your installation won’t be limited by Microsoft
Store policies, and you can control where the executable is installed and even add Python to PATH if necessary.

Installing and Managing Python Packages Using pip


With Python, you can build just about anything, from simple scripts to full applications. The Python language,
however, doesn’t come pre-installed with all of the fancy features you might want (or require). When you need
particular functionality, you can look toward Python packages. A package structures Python modules, which contain
pre-written code that other developers have created for you. Modules are handy when you are looking for specific
functionality.

You can use pip, Python’s package manager, to install and manage Python packages.

If your Python 2 version is greater than or equal to 2.7.9, no need to worry, you have pip pre-installed!

You can use pip to install packages, like so:

pip install scrapy


In the example above, pip will install the Scrapy package, a popular package (among many) used for scraping
information from websites.

There are a multitude of Python packages, which you can find on PyPI — the Python Package Index — the official
repository for third-party software for the Python programming language. PyPI is where pip grabs Python packages
from when you use pip to install a new package on your computer.

You can use pip for a variety of other things as well, which you can learn about through a quick search on the web.

Kartik Jatwani
1/18/FET/BBT/003
Program 2.

Aim: Write a program to illustrate the usage of Integer and String Values.

Code:

x=input('enter a number ')

if int(x) < 10:

print('The value is a integer and is lesser than 10')

y=input('input a string ')

d=str(y)

print('the entered string is:' "", d)

Kartik Jatwani
1/18/FET/BBT/003
Program 3.

Aim: Write a program to illustrate the usage of Identifiers, User Input, String Formatting.

Code:
"""

A Python identifier is a name used to identify a

variable, function, class, module or other object.

An identifier starts with a letter A to Z or a to z

or an underscore (_) followed by zero or more letters,

underscores and digits (0 to 9).

"""

v=input('enter a word ')

print ('here v is a identifier')

x=input('enter a number ')

if int(x) < 10:

print('The value is a integer and is lesser than 10')

y=input('input a string ')

d=str(y)

print('the entered string is:' "", d)

Kartik Jatwani
1/18/FET/BBT/003
Program 4.

Aim: Write a program to demonstrate the usage of logical operations. (e.g. greatest among three numbers).

Code:
num1=input('Enter 1st number:')

num2=input('Enter 2nd number:')

num3=input('Enter 3rd number:')

x=int(num1)

y=int(num2)

z=int(num3)

if (x>y and x>z):

print(x, ' is the greatest')

elif (y>x and y>z):

print(y, ' is the greatest')

else:

print(z , ' is the greatest')

Kartik Jatwani
1/18/FET/BBT/003
Program 5.

Aim: Write a Python program to show the usage of Loop control statements and break, continue and pass
statements.

Code:
x=input(' Enter a number between 1 and 3:')

i=int(x)

while i < 6:

print(i)

i += 1

print(' ')

y=input('Enter a number between 1 and 3:')

j=int(y)

while j < 6:

print(j)

if j == 3:

break

j += 1

j=0

print(' ')

z=input(' Enter a number between 1 and 3:')

k=int(z)

while k < 6:

k += 1

if k == 3:

continue

print(k)

Kartik Jatwani
1/18/FET/BBT/003
Kartik Jatwani
1/18/FET/BBT/003
Program 6.

Aim: Write a Python program to implement lists ( Creating, Accessing, Updating, Indexing).

Code:

# Creating a List
List = []
print("Blank List: ")
print(List)
  
# Creating a List of numbers
List = [10, 20, 14]
print("\nList of numbers: ")
print(List)

# Creating a List of strings and accessing


# using index
List = ["Geeks", "For", "Geeks"]
print("\nList Items: ")
print(List[0]) 
print(List[2])

# Update the elements at zeroth index


index = 0
num_array[index] = -1
print("num_array after update 1: {}".format(num_array))

# Update the range of elements, say from 2-7


num_array[2:7] = array('i', range(22, 27))
print("num_array after update 2: {}".format(num_array))

# Print array values using indices


print("1st array element is {} at index 0.".format(array_var[0]))
print("2nd array element is {} at index 1.".format(array_var[1]))
print("Last array element is {} at index 9.".format(array_var[9]))
print("Second array element from the tail end is {}.".format(array_var[-2]))

Kartik Jatwani
1/18/FET/BBT/003
Program 7.

Aim: Write a Python program to implement Function ( Factorial of number, finding number is prime or not).

Code:

# Python program to find the factorial of a number provided by the user.

num = int(input("Enter a number: "))

factorial = 1

if num < 0:

print("Sorry, factorial does not exist for negative numbers")

elif num == 0:

print("The factorial of 0 is 1")

else:

for i in range(1,num + 1):

factorial = factorial*i

print("The factorial of",num,"is",factorial)

# Program to check if a number is prime or not

num = int(input("Enter a number: "))

flag = False

if num > 1:

for i in range(2, num):

if (num % i) == 0:

flag = True

break

if flag:

print(num, "is not a prime number")

else:

print(num, "is a prime number")

Kartik Jatwani
1/18/FET/BBT/003
Program 8.

Aim: Write a Python program to find the largest number in array.

Code:

# Python program to find maximum in arr[] of size n 


  
def largest(arr,n):

max = arr[0]

for i in range(1, n):

if arr[i] > max:

max = arr[i]

return max

arr = [10,20,5,3,7]

n = len(arr)

Ans = largest(arr,n)

print ("Largest in given array is",Ans)

Kartik Jatwani
1/18/FET/BBT/003
Program 9.

Aim: Write a Python program to check if a string is palindrome or not.

Code:

# Program to check if a string is palindrome or not

my_str = 'aIbohPhoBiA'

my_str = my_str.casefold()

rev_str = reversed(my_str)

if list(my_str) == list(rev_str):

print("The string is a palindrome.")

else:

print("The string is not a palindrome.")

Kartik Jatwani
1/18/FET/BBT/003
Program 10.

Aim: Write a Python program to split and join a string.

Code:

#Python code to split a string

text = 'Python is a fun programming language'

print(text.split(' '))

#Python code to join a string

text = ['Python', 'is', 'a', 'fun', 'programming', 'language']

print(' '.join(text))

Kartik Jatwani
1/18/FET/BBT/003

You might also like