Welcome to the ekgurukul.com website! This Python Tutorial helps you learn the concept of language quickly and effectively. If you are not sure where to start learning Python language.
Website ekgurukul.com is a good place to start your Learning.
Python is a high-level, general-purpose and a very popular programming language. Python programming language (latest Python 3) is being used in web development, Machine Learning applications, along with all cutting edge technology in Software Industry.
Python Programming Language is very well suited for Beginners, also for experienced programmers with other programming languages like C++ and Java.
This specially designed Python tutorial will help you learn Python Programming Language in most efficient way, with the topics from basics to advanced (like Web-scraping, Django, Deep-Learning, etc.) with examples.
A scripting Python language course in computer science engineering can teach you the fundamentals of Python programming, including data types, variables, control flow, functions, and file handling. You will also learn how to use Python to automate tasks, build web applications, and develop data science projects.
Some facts about Python Programming Language:
Here are some of the benefits of taking a scripting Python language course in computer science engineering:
If you are interested in learning Python programming, a scripting Python language course in computer science engineering is a great way to get started.
Here are some of the topics that you might learn in a scripting Python language course in computer science engineering:
The difficulty of a scripting Python language course in computer science engineering will vary depending on the course's level and the instructor's teaching style. However, Python is generally considered to be one of the easiest programming languages to learn, so even beginners should be able to succeed in this type of course.
The course might also include hands-on projects that allow you to apply your skills to real-world problems.
Let’s see what’s so special in Python, what we can achieve with it, let's start Learning ...
Student can access the solutions for preparation competitive exams
num = int(input("Enter any number :")) fact = 1 n = num while num>1: fact = fact * num num - =1 print("Factorial of a number ", n , " is equal to:",fact)
OUTPUT :
Enter any number :6
Factorial of a number 6 is equal to : 720
Program to input any number from user #Check it is Prime number of not
import math num = int(input("Enter any number :"))
isPrime=True
for i in range(2,int(math.sqrt(num))+1):
if num % i == 0:
isPrime = False
if isPrime:
print("## Number is Prime ##")
else:
print("## Number is not Prime ##")
OUTPUT
Enter any number :29
## Number is Prime ##
Enter any number :57
## Number is not Prime ##
Enter any number :71
## Number is Prime ##
Enter any number :97
## Number is Prime ##
Enter any number :63
## Number is not Prime ##
#Program to find sum of elements of list recursively
def findSum(lst,num):
if num==0:
return 0
else:
return lst[num-1]+findSum(lst,num-1)
mylist = [] # Empty List
#Loop to input in list
num = int(input("Enter how many number :"))
for i in range(num):
n = int(input("Enter Element "+str(i+1)+":"))
mylist.append(n) #Adding number to list
sum = findSum(mylist,len(mylist))
print("Sum of List items ",mylist, " is :",sum)
OUTPUT
Enter how many number :6
Enter Element 1:10
Enter Element 2:20
Enter Element 3:30
Enter Element 4:40
Enter Element 5:50
Enter Element 6:60
Sum of List items [10, 20, 30, 40, 50, 60] is : 210
#Program to find 'n'th term of fibonacci series,
#Fibonacci series : 0,1,1,2,3,5,8,13,21,34,55,89,...
#nth term will be counted from 1 not 0
def nthfiboterm(n):
if n<=1:
return n
else:
return (nthfiboterm(n-1)+nthfiboterm(n-2))
num = int(input("Enter the 'n' term to find in fibonacci :"))
term =nthfiboterm(num)
print(num,"th term of fibonacci series is :",term)
OUTPUT:
Enter the 'n' term to find in fibonacci :10
10 th term of fibonacci series is : 55
#Program to find the occurence of any word in a string
def countWord(str1,word):
s = str1.split()
count=0
for w in s:
if w==word:
count+=1
return count
str1 = input("Enter any sentence :")
word = input("Enter word to search in sentence :")
count = countWord(str1,word)
if count==0:
print("## Sorry! ",word," not present ")
else:
print("## ",word," occurs ",count," times ## ")
Enter any sentence : my computer your computer our computer everyones computer
Enter word to search in sentence :computer
## computer occurs 4 times
## Enter any sentence : learning python is fun
Enter word to search in sentence :java
## Sorry! java not present
#Program to read content of file line by line #and display each word separated by '#'
f = open("file1.txt")
for line in f:
words = line.split()
for w in words:
print(w+'#',end='')
print()
f.close()
NOTE : if the original content of file is: India is my country I love python Python learning is fun
OUTPUT
India#is#my#country# I#love#python# Python#learning#is#fun#
#Program to read content of file #and display total number of vowels, consonants, lowercase and uppercase characters
f = open("file1.txt")
v=0 c=0 u=0 l=0 o=0
data = f.read()
vowels=['a','e','i','o','u']
for ch in data:
if ch.isalpha():
if ch.lower() in vowels:
v+=1
else:
c+=1
if ch.isupper():
u+=1
elif ch.islower():
l+=1
elif ch!=' ' and ch!='\n':
o+=1
print("Total Vowels in file :",v)
print("Total Consonants in file n :",c)
print("Total Capital letters in file :",u)
print("Total Small letters in file :",l)
print("Total Other than letters :",o)
f.close()
NOTE : if the original content of file is: "India is my country I love python Python learning is fun"
OUTPUT
Total Vowels in file : 16
Total Consonants in file n : 30
Total Capital letters in file : 2
Total Small letters in file : 44
Total Other than letters : 4
#Program to create a binary file to store Rollno and name #Search for Rollno and display record if found #otherwise "Roll no. not found"
import pickle
student=[ ]
f=open('student.dat','wb')
ans='y'
while ans.lower()=='y':
roll = int(input("Enter Roll Number :"))
name = input("Enter Name :")
student.append([roll,name])
ans=input("Add More ?(Y)")
pickle.dump(student,f)
f.close()
f=open('student.dat','rb')
student=[]
while True:
try:
student = pickle.load(f)
except EOFError:
break
ans='y'
while ans.lower()=='y':
found=False
r = int(input("Enter Roll number to search :"))
for s in student:
if s[0]==r:
print("## Name is :",s[1], " ##")
found=True
break
if not found:
print("####Sorry! Roll number not found ####")
ans=input("Search more ?(Y) :")
f.close()
OUTPUT
Enter Roll Number :1
Enter Name :Rajiv
Add More ?(Y)y
Enter Roll Number :2
Enter Name :Anik
Add More ?(Y)y
Enter Roll Number :3
Enter Name :Kirti
Add More ?(Y)n
Enter Roll number to search :1
## Name is : Rajiv
## Search more ?(Y) :y
Enter Roll number to search :3
## Name is : kirti
## Search more ?(Y) :y
Enter Roll number to search :5
####Sorry! Roll number not found ####
Search more ?(Y) :n
import csv
with open('myfile.csv',mode='a') as csvfile:
mywriter = csv.writer(csvfile,delimiter=',')
ans='y'
while ans.lower()=='y':
eno=int(input("Enter Employee Number "))
name=input("Enter Employee Name ")
salary=int(input("Enter Employee Salary :"))
mywriter.writerow([eno,name,salary])
print("## Data Saved... ##")
ans=input("Add More ?")
ans='y'
with open('myfile.csv',mode='r') as csvfile:
myreader = csv.reader(csvfile,delimiter=',')
while ans=='y':
found=False
e = int(input("Enter Employee Number to search :"))
for row in myreader:
if len(row)!=0:
if int(row[0])==e:
print("============================")
print("NAME :",row[1])
print("SALARY :",row[2])
found=True
break
if not found:
print("==========================")
print(" EMPNO NOT FOUND")
print("==========================")
ans = input("Search More ? (Y)")
Output :
Enter Employee Number 1
Enter Employee Name Amit
Enter Employee Salary :90000
## Data Saved... ##
Add More ?y
Enter Employee Number 2
Enter Employee Name Sunil
Enter Employee Salary :80000
## Data Saved... ##
Add More ?y
Enter Employee Number 3
Enter Employee Name Satya
Enter Employee Salary :75000
## Data Saved... ##
Add More ?n
Enter Employee Number to search :2
============================
NAME : Sunil
SALARY : 80000
Search More ? (Y)y
Enter Employee Number to search :3
============================
NAME : Satya SALARY :
75000 Search More ? (Y)y
Enter Employee Number to search :4
==========================
EMPNO NOT FOUND
==========================
Search More ? (Y)n
#Program to read line from file and write it to another line
#Except for those line which contains letter 'a'
f1 = open("file2.txt")
f2 = open("file2copy.txt","w")
for line in f1:
if 'a' not in line:
f2.write(line)
print(“## File Copied Successfully! ##”)
f1.close()
f2.close()
NOTE:
Content of file2.txt is "a quick brown fox one two three four five six seven India is my country eight nine ten bye!"
OUTPUT
## File Copied Successfully! ##
NOTE:
After copy content of file2copy.txt one two three four five six seven eight nine ten bye!
# creating list with college names..
colleges = ["SIIET", "GNIT", "AVN"]
print(colleges)
# appending new college in collges list
colleges.append("MVSR")
#checking if its added or not
print(colleges)
#adding a new college at a positon
colleges.insert(1,"BHARAT")
print(colleges)
#remove a name from colleges colleges.remove("BHARAT")
print(colleges)
#remove a name with an index value
del colleges[1]
# NOTE: index starts from 0 so 2nd value in list will be removed
print(colleges)
Output:
["SIIET", "GNIT", "AVN"]
["SIIET", "GNIT", "AVN", "MVSR"]
["SIIET", "BHARAT","GNIT", "AVN", "MVSR"]
["SIIET", "GNIT", "AVN", "MVSR"]
["SIIET", "AVN", "MVSR"]