IT Workshop*
Share more and more And comment for help
This workshop has python basics.
Python is an interpreted, high-level, and general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant whitespace. Its language constructs and object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects.
Python is dynamically typed and garbage-collected. It supports multiple programming paradigms, including structured (particularly, procedural), object-oriented, and functional programming. Python is often described as a "batteries included" language due to its comprehensive standard library.
Python was created in the late 1980s, and first released in 1991, by Guido van Rossum as a successor to the ABC programming language. Python 2.0, released in 2000, introduced new features, such as list comprehensions, and a garbage collection system with reference counting, and was discontinued version 2.7 in 2020. Python 3.0, released in 2008, was a major revision of the language that is not completely backward-compatible and much Python 2 code does not run unmodified on Python 3. With Python 2's end-of-life, only Python 3.6.x and later are supported, with older versions still supporting e.g. Windows 7 (and old installers not restricted to 64-bit Windows).
Python interpreters are supported for mainstream operating systems and available for a few more (and in the past supported many more). A global community of programmers develops and maintains CPython, a free and open-source[31] reference implementation. A non-profit organization, the Python Software Foundation, manages and directs resources for Python and CPython development.
As of December 2020, Python ranked third in TIOBE’s index of most popular programming languages, behind C and Java.
Download File of ITW Download
S.no | Title | Remarks |
1 | Introduction to Python. |
|
2 | Write down the complete step by step installation process of python. |
|
3 | How python is different from JAVA And PHP. |
|
4 | Write a program to compute the GCD of the two numbers. |
|
5 | Write a program to find the square root of a number. |
|
6 | Write a program to find the exponentiation(power) of a number. |
|
7 | Write a program to find out the maximum of a list of numbers. |
|
8 | Write a program for performing BODMAS operation ( Addition, Subtraction, Multiplication, Division) by taking input from the user for both number and operation performed. |
|
9 | Write a program to find whether its a leap year or not. |
|
10 | Write a program to find out the factorial of a number. |
|
11 | Write a program to find out the Fibonacci series. |
|
12 | Write a program to find out the linear search. |
|
13 | Write a program for the multiplication table of a number. |
|
14 | Write a program to count the number of vowels from a string. |
|
Practical-1
Aim: Introduction to python.
Solution:
Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.
It is used for:
· web development (server-side)
· software development
· mathematics
· system scripting.
What can Python do?
· Python can be used on a server to create web applications.
· Python can be used alongside software to create workflows.
· Python can connect to database systems. It can also read and modify files.
· Python can be used to handle big data and perform complex mathematics.
· Python can be used for rapid prototyping, or for production-ready software development.
Why Python?
· Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
· Python has a simple syntax similar to the English language.
· Python has a syntax that allows developers to write programs with fewer lines than some other programming languages.
· Python can be treated in a procedural way, an object-oriented way, or a functional way.
Practical-2
Aim: Write down the complete step by step installation process of python.
Solution:
(a) Installation Steps
Step 1: Download Python from www.python.org
Step 2: Install Python in our System
Step 3: Open Command Prompt and Run ‘ Python ‘ .
it means Python is successfully installed in our System.
Step 4: Search ‘ IDLE’ in the search bar and press enter.
Step 5: Press Enter
Hence We get the Python Shell Window, Now We Will Start Coding Challenges.
Practical-3
Aim: How python is different from JAVA And PHP.
Solution:
Python vs PHP
· Python is a high-level object-oriented programming language used for rapid application development whereas PHP stands for Hypertext pre-processor used to develop a dynamic website or web application.
· Python is widely used in AI, data science, and scientific community whereas PHP is the language of choice for web development.
· Python has a small number of frameworks whereas PHP has many frameworks.
· Python offers very clear and concise syntax of codes whereas PHP has a wide range of naming conventions and syntax.
· Key features of Python are Rapid development, Dynamic typing and beautiful code whereas Key features of PHP are Open source, Easy Deployment, Continual Improvements.
Python vs JAVA
· Python takes less time to develop although it is expected to run slower than Java programs
· Due to Python high-level data types and its dynamic typing programs are shorter than Java programs
Practical-4
Aim: Write a program to compute the GCD of the two numbers.
Solution:
name = input("What is your name ?")
print(name)
num1 = int(input("Enter 1st number\n"))
num2 = int(input("Enter 2nd number\n"))
if num1>num2:
min = num1
else:
min = num2
for i in range(1,min+1):
if num1%i==0 and num2%i ==0:
hcf = i
print("Gcd of these two numbers is : ",hcf)
Output:
Practical-5
Aim: Write aprogram to find the square root of a number.
Solution:
name = input("What is your name ?")
print(name)
digit = int(input("Enter a digit for its Square Root : \n"))
print("The square root of", digit, "is : %.2f" % (digit ** .5))
Output:
Practical-6
Aim: Write a program to find the exponentiation(power) of a number.
Solution:
name = input("What is your name ?")
print(name)
digit = int(input("Enter the digit\n"))
power = int(input("enter the power"))
print(digit, "to the power", power, " is equal to %.2f :" % (digit ** power))
Output:
Practical-7
Aim: Write a program to find out the maximum of a list of numbers.
Solution:
mylist = [1, 8, 3, 4, 7, 6]
max = mylist[0]
for i in range(0,(len(mylist)-1)):
if mylist[i] > max:
max = mylist[i]
print(max, "is maximum value in the list")
Output:
Practical-8
Aim: Write a program for performing BODMAS operation ( Addition, Subtraction, Multiplication, Division) by taking input from the user for both number and operation performed.
Solution:
name = input("What is your name ?")
print("My name is ",name)
var1 = int(input("Enter First Number: "))
var2 = int(input("Enter Second Number: "))
result=0
ch = input('''Enter which operation would you like to perform?
"+" for Addition
"-" for Subtraction
"/" for Division
"*" for Multiplication \n''')
if ch == '+':
result = var1 + var2
elif ch == '-':
result = var1 - var2
elif ch == '*':
result = var1 * var2
elif ch == '/':
result = var1 / var2
else:
print("You Choose Wrong Character!!!")
print(var1,ch,var2, ":", result)
Output:
Practical-9
Aim: Write a program to find whether its a leap year or not.
Solution:
name = input("What is your name ?")
print("My name is ",name)
year = int(input("Enter year to check whether it is leap or not?\n"))
if year % 4 == 0:
print(year, "is a leap year")
else:
print(year, "is not a leap year")
Output:
Practical-10
Aim: Write a program to find out the factorial of a number.
Solution:
print("My name is Hritik")
def FactorialOfNumber(n):
if (n==1 or n==0):
return 1
else:
return (n * FactorialOfNumber(n - 1))
num = int(input("Enter the value "))
print("Factorial of " + str(num) + " is" ,FactorialOfNumber(num))
Output:
Practical-11
Aim: Write a program to find out the fibonacci series.
Solution:
name = input("What is your name ?")
print(name)
def fibonacciSeries(x):
a = 0
b = 1
if x==0:
return a
elif x==1:
return b
else:
print("0 1 ",end=" ")
for i in range(1,n-1):
c = a + b
a = b
b = c
print(c," ",end="")
n = int(input("Enter the digit for fibonacci series :"))
fibonacciSeries(n)
Output:
Practical-12
Aim: Write a program to find out the linear search.
Solution:
list =[]
n = int(input("Enter number of of elements :\n"))
print("Enter elements : ")
for i in range(1,n+1):
element = int(input())
list.append(element)
print("You entered : ",list)
find = int(input("Enter the element you want to search :"))
for j in range(len(list)):
if list[j]==find:
print(list[j] ,"is found at Position","(",j+1,")")
break
else:
print("Element is not found")
Output:
Practical-13
Aim: Write a program for the multiplication table of a number.
Solution:
name = input("What is your name ?")
print("My name is ",name)
value = int(input("Enter the number For complete table: "))
print("Multiplication Table of", value ," is :-")
for i in range(1, 11):
print(value,"x",i,"=",value * i)
Output:
Practical-14
Aim: Write a program to count the number of vowels from a string.
Solution:
name = input("What is your name ?")
print(name)
mystring = input("Enter a string: \n")
vowels = "aeiou"
count = 0
loweredString = mystring.lower()
for i in loweredString:
for j in vowels:
if i == j:
count = count +1
print("Number of vowels in the string is ", count)
Output:
Comments
Post a Comment