It took just 3-4 days for understanding basic syntax of python without holding other works because of your videos. These are to the point videos. Each minute has valid content. Thanks to You Mr. Naveen. Our colleges need teachers like you.
I was "Zero" in any programming, Now all my daily jobs is running with python, Because of Mr Naveen Reddy. Thank you sir, The way you teach is nothing but a solution you provide.
MAN, you're amazing teacher and I could learn this much python in 3 days and its because of you. I like your slang and also the teaching methods. Even after 2 yrs, yours is awesome one during search of course in youtube. Done well congrats :D
I possess a full Udemy course regarding Python3 and I'm quite good in python after finishing 70% of the course.. But I think it could have been better if I took Python3 knowledge from your lectures... Kudos to you reddy ji!!! ❤️❤️
qn1. from array import * vals = array('i',[2,8,1,9,12]) for i in sorted(vals): print(i) qn2. from math import * num = int(input('kindly enter your number')) print(math.factorial(num))
bhai galat hh factorial ki value sidha dega yeh printing me x=int(input("enter any value")) fact=1 for i in range(1,x): fact=fact*i print(fact) yeh shii solution hhh
@@crosswalker45 Reverse method parameter ni leta And sorted takes parameter.. That's why sorted(list) will work...and for working reverse, you need to directly call this with list..without any parameter..like List.reverse() This sending me one who doing programming
hello sir a simple request from side. could you please write assignment questions in description instead of showing them in end of video. If you do it for making suspense then it is okay but please show them in left bottom side instead of showing them on top because at the end of the video telusko logo comes and questions got invisible. So please consider this request. Thank You.. you are doing great!!
#1-sorting from array import * arr=array('i',[11,7,9,6,-4,3,5]) for i in range(len(arr)): for j in range(i+1,len(arr)): if(arr[i]>arr[j]): arr[i],arr[j]=arr[j],arr[i] print(arr) #2-factorial number=int(input("Enter a number:")) value=1 for i in range(1,number+1): value=value*i print(f"factoiral of {number} is",value)
Answers: (a) from array import * a=array('i', [12,10,18,2,17,29]) print(sorted(a)) (b) a = int(input("Enter any number: ")) for i in range(1, a): a = a*i print(a)
For solution of 1 : #To sort an array in ascending order from array import * vals = array('i', [1, 3, 8, 9, 2]) for i in range(len(vals)): for j in range(len(vals)): if( vals[i] < vals[j] ): a = vals[i] vals[i] = vals[j] vals[j] = a for i in range(len(vals)): print(vals[i])
1) from array import * valori = array('i',[2,4,8,7,3,42,109,10000,100908]) while True: print(sorted(valori)) break 2) from math import* x=int(input("Qual è il fattoriale di questo numero?")) while True: print(factorial(x)) break
def f(x): if x==1: return 1 else: return (f(x-1)*x) x=int(input("Enter:")) print(f(x)) Code for finding factorial of a number I have used the method of recursion here
Answer1 from array import * b=array('i',[]) n=int(input("Enter the length of array")) for i in range(n): x=int(input("Enter the next value")) b.append(x) for i in range(len(b)): for j in range(i+1,len(b)): if b[i]>b[j]: b[i],b[j]=b[j],b[i] print(b) Answer 2: n=int(input("Enter a number of which you want to find factorial for")) for i in range(n-1,0,-1): n=n*i print(n) print("The factorial of the given number is",n)
## Sort array using selection sort ### import array as arr """ selection sort """ val = arr.array('i',[4, 5,-5,-12, 6, 7, -8]) print("before sort:",val) for a in range(len(val)-1): for b in range(a+1,len(val)): if val[a] > val[b]: val[a],val[b] = val[b],val[a] print(" after sort:",val)
I'm learning python almost 1month but I have no much knowledge about array or others.. But when I start watching your tutorial, I have got much knowledge and improve myself. Thanks sir..
from array import * values = array("i", [7,4,9,2,6,2,1]) x=len(values) for i in range(x): for j in range(i+1, x): if values[i]>values[j]: temp = values[i] values[i]=values[j] values[j]=temp print(values)
1: from array import * vals = array ('i', [2,4,-6,8,] ) svals = sorted(vals) print(svals) 2: n= int(input("Enter the value of a number")) factorial=1 while n>1: factorial=factorial*n n=n-1 print(factorial)
The way you teach is really awesome, not making any confusion, sometimes we really want to have some doubt to ask but you are making it a bit difficult to have doubt☺️☺️
program 1 from array import* vals= array('i',[2,5,1,3,6,4,9,8,7]) print(sorted(vals)) program 2 from math import* x= int(input('enter a no')) print(factorial(x))
1) import array as a v=a.array('i',[98,76,56,99,45,44]) print(sorted(v)) 2) i think second assignment question is factorial of given number import math num=int(input("enter the number which your going to do factorial : ")) b=math.factorial(num) print(b) or import math as a num=int(input("enter the number which your going to do factorial : ")) b=a.factorial(num) print(b) or from math import factorial num=int(input("enter the number which your going to do factorial : ")) l=factorial(num) print(l)
On the 26th tutorial. starting as a complete Noob! however... your videos may be making me over confident lol. other than your very fast dialect you are one of the greatest teachers i have yet to encounter lol. thank you for posting these videos. Your hard work is very much appreciated.
Factorial Algorithm created by me without using any prebuild function: print ( "Enter a Number to find its factorial: " , end="" ) inp = int ( input( ) ) ans = 1 for x in range ( inp ) : ans = ans * ( x + 1 ) print ( "Factor of" ,inp, "is:" ,ans )
a=int(input("enter any number ")) c=0 for i in range(1,a+1): if a%i==0: c=c+1 print(i,"are the factors") if(c==2): print(a,"is prime no") else: print(a,"is composite number") print("total number of factors",c)
Sir... copying array works like simple variable assignment. array1 = newArr, we don't need to use typecode, for and all. It worked. :) #Arrays in python, copy one array to other array from array import * intArr = array('i',[1,2,4,6,8,3,7]) intArr2 = intArr #assgn (copy) intArr to new array intArr2 for e in intArr2: print(e) Output: 1 2 4 6 8 3 7 Process finished with exit code 0
assigning old array to new: vals=array('i',[1,2,3,4]) newarray=vals this above statement also works then why we are doing this:- newarray=array(vals.typecode,(a for a in vals))
@@kalyan762 Here, "for a in vals" is similar to for loop, where "a" is a variable,used to traverse the vals. It picks values of array one by one and do the operation, since here only a(before for) is present it copies the array as it is. The only benefit of using this concept is that,we can do certain operations with all the values of vals and stores it in a new array but this is not possible with the syntax ->(newarray=vals) Ex-> newarray=array(vals.typecode,(3*a for a in vals)) ,multiplies every element of array with 3 and stores it in new array. Hope this will help you :)
from array import * a = array('i', [5, 4, 2, 3, 1, 56, 1]) print(a) for i in range(len(a)): for j in range(len(a)): if a[i] < a[j]: a[i], a[j] = a[j], a[i] print(a)
Solution for no 1 from array import array as a nums = a("i",[99,85,57,91,100]) l = list(a for a in nums) l.sort() nums = a("i",(a for a in l)) print(nums)
for array in ascending order: from array import array value=array('i',[9,8,5,0,2,7]) a=sorted(value) print(a) for factorial of given number: import math a=int(input("enter num:")) print(math.factorial(a))
sorting an array without using inbuilt function from array import * arr = array('i',[6,23,44,21]) for i in range(4): for j in range(i+1): if arr[j]>arr[i]: arr[j],arr[i] = arr[i],arr[j] for x in range(4): print(arr[x])
"""lets try and sort an array in ascending order""" from array import * vals=array('i',[9,2,8,6,7]) print(vals) for i in range(5): for j in range(i+1,5): if vals[i]>=vals[j]: vals[i],vals[j]=vals[j],vals[i] print(vals)
@@gauravmalhotra007No limits in programming. There are multiple ways of doing it since people take different approach, the most preferred method is the simple one to save memory. . >>>vals.sort(reverse = True)
I should thank you for Python Videos, I have spent lot of money for coaching center and learnt nothing. this is the best tutorial till now I found. many thanks to you.
#-----finding a given number in an array----- x= int(input("enter the no you wanna find in the array")) for i in range(len(vals)): if x==vals[i]: print("no is present at location : ",i+1) break else: print("no luck")
actually i think my logic is wrong,ad on decrementing x also,nothing will happen.... u check on ur complier u'll know. Btw, do u know from where to learn ML
2) Factorial from array import * num = int(input("enter the number")) x = list() while num > 0: x.append(num) num = num - 1 print(x) y = int(1) for i in x: y = i * y print(y)
#sorted arrays from array import * vals = array("i" ,[5,9,11,16,3,10,2,1,6]) values = array(vals.typecode , (i for i in vals)) values = sorted(values) for i in values: print(i) #factorial from math import * x = int(input("Enter the number:")) for i in range(x): x = factorial(x) print(x) break
finally i have command over range in python, here is solution for Q2: x=int(input("factorial of which num you want")) f=1 for i in range(x+1,1,-1): print(f, "*", i," = ",end=" ") f=f*i print(f) print("process complete: factorial of ",x," is :",end=" ") print(f) glad to learn python with navin, thank you.
array sort: ------------------ ascending order: import array vals=array.array('i',[5,2,3,4,1,6]) n=len(vals) for e in range(n): for j in range(1,n-e): if vals[j-1]>vals[j]: (vals[j-1],vals[j])=(vals[j],vals[j-1]) print(vals)
To find the factorial of a given number without using math.factorial n=int(input("Enter a number")) if n0: p=n for a in range(1,n): m=p*a if a==n-1: print(m) elif a
PROGRAM1: from array import array arr = array('i',[5,4,3,2,0]) for i in range(len(arr)-1): j=0 while jarr[j+1]: t=arr[j] arr[j]=arr[j+1] arr[j+1]=t j+=1 for e in arr: print(e,end=" ") PROGRAM2: x = int(input("Enter a number to find factorial: ")) fact=1 while x>1: fact*=x x-=1 print("Factorial = ",fact)
Great! But it does not work for a=0 (i.e. 0! = 1) Solution (considering only positive or null values of a): a = int(input("Enter any number: ")) f = 1 for i in range(1,a+1): f *= i print(f)
1. A code to sort the array in ascending order alphabets = array('u', ['a', 'q', 'b', 'k', 'z', 'f']) print(sorted(alphabets)) nums = array('i', [55, 7, 0, 65, 20, 34]) print(sorted(nums)) 2. A code to find the factorial of given number fact = array('i', [2, 5, 3, 7]) for f in fact: print(factorial(f))
Sir whole day we eagerly wait for your quality, elaborately discussed videos but recently someday you don't upload even a single video.. Please sir at least upload two your quality videos daily 🙏🙏..
The best videos i have ever seen... U discussed every basic , which is extremely extremely extremely beneficial 😍😍... I m a beginner and also faced a lot of difficulties.. but after seeing ur vdos , now i m clear about python.. my next mission is Django... And i will follow ur videos so that I don't face any kind of difficulties...thank you sooooooooooooooo muchh🥰🥰🥰🥰🥰🥰
2nd assignnment: fac = int(input("enter a number to get factorial")) import math as m result = m.factorial(fac) print(result) /////this is for loop concept for factorial s=1; for i in range(1,fac+1): s=s*i print(s)
It took just 3-4 days for understanding basic syntax of python without holding other works because of your videos. These are to the point videos. Each minute has valid content. Thanks to You Mr. Naveen. Our colleges need teachers like you.
That's right
Bro I truly agree
that's call comment
It took me 3-4 days to understand what he is saying.
Visual information is the best way of learning something
India needs more teacher like u....we pay laks of fees to clg and learns nothing .
it is clear!
I see you didn't learn English too
@@pragyanbimali66 can we get English class tutorial from you..
😭🤣
@@shameelsha sure!
wtf? Almost everytime when i try to guess new things and searching, always this man is on first page with best tutorials. Thank you man))
One reason being, Google/RUclips filters content according to your preferences. 😄
Oh i got to know array in Python is new thing!!
this generation kids use bad words fluently without hesitation bruh
~wise kid
@@anonymous-w6y+1 For U😂❤
I was "Zero" in any programming, Now all my daily jobs is running with python, Because of Mr Naveen Reddy. Thank you sir, The way you teach is nothing but a solution you provide.
MAN, you're amazing teacher and I could learn this much python in 3 days and its because of you. I like your slang and also the teaching methods. Even after 2 yrs, yours is awesome one during search of course in youtube. Done well congrats :D
Started following your videos on Python. Your way of explanation is amazing. Our country needs teacher like you :)
I possess a full Udemy course regarding Python3 and I'm quite good in python after finishing 70% of the course.. But I think it could have been better if I took Python3 knowledge from your lectures...
Kudos to you reddy ji!!!
❤️❤️
U9yt
qn1.
from array import *
vals = array('i',[2,8,1,9,12])
for i in sorted(vals):
print(i)
qn2.
from math import *
num = int(input('kindly enter your number'))
print(math.factorial(num))
To find factor of a given number:
Import math as m
a = int(input("Enter your number: "))
print(m.factorial(a))
that helps thank you :)
@@NikSy 'import' ( lowercase i ) :-)
How did u get this??
bhai galat hh factorial ki value sidha dega yeh printing me
x=int(input("enter any value"))
fact=1
for i in range(1,x):
fact=fact*i
print(fact)
yeh shii solution hhh
from array inport*
vals=array('i,[1,2,3,4])
i=0
while i
It just prints 1 infinitely bro and there are typo mistakes .
#ArraySorting
from array import array
x = array('I',[0,10,7,2,63,19])
print(sorted(x))
import array
a=array.array('i', [23,22,56,97,-68])
b=sorted(a)
for i in b:
print(i)
It would be better in case you want integers individually
@@dhruvdutt2749 Why arrray.array, array( , ) is sufficient na?
@@harikpriyatirumalaraju674 not in my situation
Dhruv Dutt why?
@@harikpriyatirumalaraju674 because i used import array instead of From array import Array/ From array import *
Great learning experience. Thanks a lot sir. Atleast a guy like me who didn't had any interest in computers , started watching and practicing Python .
"welcome back aliens" never thought I would enjoy this sentence
But we r humans 🦍🦍🦍
@@stockfish3379 are we?
@@stockfish3379 we are aliens wrt the aliens
Perfect said
@tcfreestyler123x what is that
print("Factorial finding machine")
user= int(input("Please enter you number"))
a=1
b=1
for i in range(1,user+1):
if i
Second answer
number=int(input(type number))
factorial=1
for I in range(1,number+1):
factorial=factorial*i
print(factorial)
Awesome bro
Factorial*I
q-2 searching number
import array as arr
nums=arr.array('i',[9,16,13,12])
i=0
value=int(input("enter the value to search"))
while i
The quiz questions at the end are being covered. Can you please mention it in the description
true the sub button must be placed at bottom right
from array import*
valu = array('i',[5,4,3,2,1])
vals = sorted(valu)
newarr = array(valu.typecode,vals)
for e in newarr:
print(e)
1) from array import *
vals=array('i',[1,50,8,25,91,22])
vals=sorted(vals)
print(vals)
Why we haven't be use sorted like
vals.sorted()
But we use reverse
vals.reverse() like this???
@@priyanshupatel02 same doubt,,,,,I think it is based on somthing like return function,,,,If u got the answer,,then plz let me know too!!
@@crosswalker45 Reverse method parameter ni leta
And sorted takes parameter..
That's why sorted(list) will work...and for working reverse, you need to directly call this with list..without any parameter..like List.reverse()
This sending me one who doing programming
For factorial of a number
x=int(input('Please enter your number'))
j=i=1
while i
hello sir
a simple request from side.
could you please write assignment questions in description instead of showing them in end of video.
If you do it for making suspense then it is okay but please show them in left bottom side instead of showing them on top because at the end of the video telusko logo comes and questions got invisible.
So please consider this request.
Thank You.. you are doing great!!
Your explanation is very nice 👍👍
#1-sorting
from array import *
arr=array('i',[11,7,9,6,-4,3,5])
for i in range(len(arr)):
for j in range(i+1,len(arr)):
if(arr[i]>arr[j]):
arr[i],arr[j]=arr[j],arr[i]
print(arr)
#2-factorial
number=int(input("Enter a number:"))
value=1
for i in range(1,number+1):
value=value*i
print(f"factoiral of {number} is",value)
instead of using value = value * i you can use value *= i to make it simpler
Answers:
(a)
from array import *
a=array('i', [12,10,18,2,17,29])
print(sorted(a))
(b)
a = int(input("Enter any number: "))
for i in range(1, a):
a = a*i
print(a)
num = 1
x = int(input("Enter the Number:\t"))
for i in range(1, x+1):
num = i * num
print(num)
answer of 2nd question is
import math
a = int(input("Enter your number: "))
print(math.factorial(a))
bhai galat hh isme direct value print kr dega
x=int(input("enter any value"))
fact=1
for i in range(1,x):
fact=fact*i
print(fact)
Thank you sir🎉
For solution of 1 :
#To sort an array in ascending order
from array import *
vals = array('i', [1, 3, 8, 9, 2])
for i in range(len(vals)):
for j in range(len(vals)):
if( vals[i] < vals[j] ):
a = vals[i]
vals[i] = vals[j]
vals[j] = a
for i in range(len(vals)):
print(vals[i])
1)
from array import *
valori = array('i',[2,4,8,7,3,42,109,10000,100908])
while True:
print(sorted(valori))
break
2)
from math import*
x=int(input("Qual è il fattoriale di questo numero?"))
while True:
print(factorial(x))
break
❤❤❤❤🎉🎉
def f(x):
if x==1:
return 1
else:
return (f(x-1)*x)
x=int(input("Enter:"))
print(f(x))
Code for finding factorial of a number
I have used the method of recursion here
i wish i had professors or HOD like him engineering would have been heaven
Answer1
from array import *
b=array('i',[])
n=int(input("Enter the length of array"))
for i in range(n):
x=int(input("Enter the next value"))
b.append(x)
for i in range(len(b)):
for j in range(i+1,len(b)):
if b[i]>b[j]:
b[i],b[j]=b[j],b[i]
print(b)
Answer 2:
n=int(input("Enter a number of which you want to find factorial for"))
for i in range(n-1,0,-1):
n=n*i
print(n)
print("The factorial of the given number is",n)
## Sort array using selection sort ###
import array as arr
""" selection sort """
val = arr.array('i',[4, 5,-5,-12, 6, 7, -8])
print("before sort:",val)
for a in range(len(val)-1):
for b in range(a+1,len(val)):
if val[a] > val[b]:
val[a],val[b] = val[b],val[a]
print("
after sort:",val)
from array import *
val = array('i',[21,15,43,-66,100])
print("sorted array = ", sorted(val))
import math as m
x=int(input('enter the number;-'))
print(m.factorial(x))
I'm learning python almost 1month but I have no much knowledge about array or others.. But when I start watching your tutorial, I have got much knowledge and improve myself.
Thanks sir..
from array import *
v=array('i',[12,3,5,6,1,0])
p=sorted(v)
print(p)
Code to arrange in ascending order
from array import *
values = array("i", [7,4,9,2,6,2,1])
x=len(values)
for i in range(x):
for j in range(i+1, x):
if values[i]>values[j]:
temp = values[i]
values[i]=values[j]
values[j]=temp
print(values)
for swap u csn use a[i],a[j]=a[j],a[i]
Here you use selection sort algorithm am I correct?
n = int(input('Enter the Number= '))
for i in range(1,n):
n = n*i
print('Factorial of the Number is=',n)
from array import *
a=array('i' , [2,6,5,0,1])
b=array('i',[])
for y in range(max(a)+1):
if y in a:
b.append(y)
else:
pass
print(b)
it cannot order the negative numbers i-e(-6)
1:
from array import *
vals = array ('i', [2,4,-6,8,] )
svals = sorted(vals)
print(svals)
2:
n= int(input("Enter the value of a number"))
factorial=1
while n>1:
factorial=factorial*n
n=n-1
print(factorial)
The way you teach is really awesome, not making any confusion, sometimes we really want to have some doubt to ask but you are making it a bit difficult to have doubt☺️☺️
Best tutor on RUclips for Python!
program 1
from array import*
vals= array('i',[2,5,1,3,6,4,9,8,7])
print(sorted(vals))
program 2
from math import*
x= int(input('enter a no'))
print(factorial(x))
Print(math.factorial(x))
I love your way of explaining,as you first do it wrong,then tell us the write method.
Thank You 😀😀
Thank Q sir,We are paying fee in colleges but it does'nt give the practical Knowledge,but your are giving your best.Keep doing videos and inspire many
1)
import array as a
v=a.array('i',[98,76,56,99,45,44])
print(sorted(v))
2) i think second assignment question is factorial of given number
import math
num=int(input("enter the number which your going to do factorial : "))
b=math.factorial(num)
print(b)
or
import math as a
num=int(input("enter the number which your going to do factorial : "))
b=a.factorial(num)
print(b)
or
from math import factorial
num=int(input("enter the number which your going to do factorial : "))
l=factorial(num)
print(l)
On the 26th tutorial. starting as a complete Noob! however... your videos may be making me over confident lol. other than your very fast dialect you are one of the greatest teachers i have yet to encounter lol. thank you for posting these videos. Your hard work is very much appreciated.
Ascending program
from array import *
a=array(‘i’, [1,3,9,8,2,5]
y=sorted(a)
print(y)
output: [1,2,3,5,7,9]
Descending progarm
from array import *
a=array(‘i’, [1,3,9,8,2,5]
y=sorted(a)
y.reverse()
print(y)
output: [9,7,5,3,2,1]
factorial program
from math import *
n=int(input(“enter a number”)
f=factorial(n)
print(f)
from array import *
yes = array('i',[33,44,22,11])
print(sorted(yes))
in qustion, it is asked for alphabet arrangement
am telling you you've done a good job... i went in the bush.... lol
thnx man it helped me
bro where you get aaray in pycham aaray is working
Lol write the code in loop not pre defined functions 💩💩💩💩🤦♂️💩💩
For finding the factorial of a number:-
x = int(input("enter the number"))
y=1
if(x
Factorial Algorithm created by me without using any prebuild function:
print ( "Enter a Number to find its factorial: " , end="" )
inp = int ( input( ) )
ans = 1
for x in range ( inp ) :
ans = ans * ( x + 1 )
print ( "Factor of" ,inp, "is:" ,ans )
very good
2.ans
import math as m
x=int(input("enter num of you want factorial"))
print(m.factorial(x))
n=int(input("no.?"))
i=1
out=1
while i
nice ,different solution
Fk it's working
a=int(input("enter any number "))
c=0
for i in range(1,a+1):
if a%i==0:
c=c+1
print(i,"are the factors")
if(c==2):
print(a,"is prime no")
else:
print(a,"is composite number")
print("total number of factors",c)
sir im enjoying the python course
you are doing such A GRAET WORK
Sir... copying array works like simple variable assignment. array1 = newArr, we don't need to use typecode, for and all. It worked. :)
#Arrays in python, copy one array to other array
from array import *
intArr = array('i',[1,2,4,6,8,3,7])
intArr2 = intArr #assgn (copy) intArr to new array intArr2
for e in intArr2:
print(e)
Output:
1
2
4
6
8
3
7
Process finished with exit code 0
n=int(input("Enter the number whose factorial you want to know: "))
m=1
for i in range(1,n+1):
m=m*i
print(m)
Why n+1 ??
@@soumsgaming238 because it will go from 1 to n.. definition of range
@@hritwikhaldar9272 Accha thank you I am learning python
Hritwik Haldar Hey a try fixing your code bit ! It doesn’t work if I give 0 😁😉
Telusko is the Best Channel on the Earth to Learn Programming! Hats Off... Dear Navin!
assigning old array to new:
vals=array('i',[1,2,3,4])
newarray=vals
this above statement also works then why we are doing this:-
newarray=array(vals.typecode,(a for a in vals))
What happens in a for a in vals? I didnt get that
@@kalyan762 Here, "for a in vals" is similar to for loop, where "a" is a variable,used to traverse the vals. It picks values of array one by one and do the operation, since here only a(before for) is present it copies the array as it is.
The only benefit of using this concept is that,we can do certain operations with all the values of vals and stores it in a new array but this is not possible with the syntax ->(newarray=vals)
Ex-> newarray=array(vals.typecode,(3*a for a in vals)) ,multiplies every element of array with 3 and stores it in new array.
Hope this will help you :)
@@sameernayak9611 thanks a lot for such clear explanation
a=int(input("enter number"))
fact=1
i=1
while(i
no=int(input("Enter any number: "))
fact=1
for n in range(no,1,-1):
fact=fact*n
print("The factorial of ",no," is: ",fact)
In range u have to give 0 in 2nd place
Not 1 😔
She saved time by eliminating multiplication with 1.
from array import *
a = array('i', [5, 4, 2, 3, 1, 56, 1])
print(a)
for i in range(len(a)):
for j in range(len(a)):
if a[i] < a[j]:
a[i], a[j] = a[j], a[i]
print(a)
Solution for no 1
from array import array as a
nums = a("i",[99,85,57,91,100])
l = list(a for a in nums)
l.sort()
nums = a("i",(a for a in l))
print(nums)
You may also use nums only in place of a for a in nums, just to improve efficiency
for array in ascending order:
from array import array
value=array('i',[9,8,5,0,2,7])
a=sorted(value)
print(a)
for factorial of given number:
import math
a=int(input("enter num:"))
print(math.factorial(a))
sorting an array without using inbuilt function
from array import *
arr = array('i',[6,23,44,21])
for i in range(4):
for j in range(i+1):
if arr[j]>arr[i]:
arr[j],arr[i] = arr[i],arr[j]
for x in range(4):
print(arr[x])
from array import *
import math
a = array('i',[])
i = 1
j = int(input('How many nums:
'))
while(i
"""lets try and sort an array in ascending order"""
from array import *
vals=array('i',[9,2,8,6,7])
print(vals)
for i in range(5):
for j in range(i+1,5):
if vals[i]>=vals[j]:
vals[i],vals[j]=vals[j],vals[i]
print(vals)
It works but it's not efficient..
@@leepierrelephiri7944 any suggestions..wat can be done? pls help
@@gauravmalhotra007No limits in programming. There are multiple ways of doing it since people take different approach, the most preferred method is the simple one to save memory.
.
>>>vals.sort(reverse = True)
@@leepierrelephiri7944 thank u
@@gauravmalhotra007 '''vals[i],vals[j]=vals[j],vals[i]''' can you plz help explain me this line!!!!
I should thank you for Python Videos, I have spent lot of money for coaching center and learnt nothing. this is the best tutorial till now I found. many thanks to you.
I like the style in the end of every video--" ba biie" 🤭🤭😂😂
...
#-----finding a given number in an array-----
x= int(input("enter the no you wanna find in the array"))
for i in range(len(vals)):
if x==vals[i]:
print("no is present at location : ",i+1)
break
else: print("no luck")
#Factorial
num=int(input("Enter number: "))
fact=1
while(num>0):
fact*=num
num-=1
print("factorial is: ",fact)
why my program is not working
x=int(input('enter a no'))
num=1
while x>num:
x=x*num
num=num+1
print(x)
lol,my num is 1, how can i make it num-1, it will go to zero then negative
actually i think my logic is wrong,ad on decrementing x also,nothing will happen....
u check on ur complier u'll know.
Btw, do u know from where to learn ML
@@neelesh621 nope i don't know
2) Factorial
from array import *
num = int(input("enter the number"))
x = list()
while num > 0:
x.append(num)
num = num - 1
print(x)
y = int(1)
for i in x:
y = i * y
print(y)
#sorted arrays
from array import *
vals = array("i" ,[5,9,11,16,3,10,2,1,6])
values = array(vals.typecode , (i for i in vals))
values = sorted(values)
for i in values:
print(i)
#factorial
from math import *
x = int(input("Enter the number:"))
for i in range(x):
x = factorial(x)
print(x)
break
2nd quiz question answer
x = input("enter the number for the factorial")
i = 1
fact = 1
while i
finally i have command over range in python,
here is solution for Q2:
x=int(input("factorial of which num you want"))
f=1
for i in range(x+1,1,-1):
print(f, "*", i," = ",end=" ")
f=f*i
print(f)
print("process complete: factorial of ",x," is :",end=" ")
print(f)
glad to learn python with navin,
thank you.
num=8
fact=1
if fact
shouldn't it be num instead of fact in if else statement
Keepe Print(fact) with for loop
Otherwise it will print all the values
array sort:
------------------
ascending order:
import array
vals=array.array('i',[5,2,3,4,1,6])
n=len(vals)
for e in range(n):
for j in range(1,n-e):
if vals[j-1]>vals[j]:
(vals[j-1],vals[j])=(vals[j],vals[j-1])
print(vals)
You are a very good teacher. Love your Python tutorials! Thank you!!
To find the factorial of a given number without using math.factorial
n=int(input("Enter a number"))
if n0:
p=n
for a in range(1,n):
m=p*a
if a==n-1:
print(m)
elif a
from array import *
arr=array('i',[3,8,5,9,3,6])
arr1=sorted(arr)
print(arr1)
For descending order?
@@Rajkumar-vc2pg just type above print(arr1)
arr1.reverse() then you will get decending order
@@raghavchakravorthy3896 yea I'm liking that.. But i don't think it is efficient way to do
factorial???
Sort not working in array
Finally the wait is over 2 days was a long time without you sir😊
We love you sir
PROGRAM1:
from array import array
arr = array('i',[5,4,3,2,0])
for i in range(len(arr)-1):
j=0
while jarr[j+1]:
t=arr[j]
arr[j]=arr[j+1]
arr[j+1]=t
j+=1
for e in arr:
print(e,end=" ")
PROGRAM2:
x = int(input("Enter a number to find factorial: "))
fact=1
while x>1:
fact*=x
x-=1
print("Factorial = ",fact)
2nd
import math
x=int(input(" enter the value"))
var=math.factorial(x)
print(var)
Hehe, nice work lazy dude!
how can i repeat this script?
after getting the result it should ask for another number to enter
thank you sir you make it so easy to understand
2)
a=int(input("Enter any number:"))
for i in range(1,a):
a=a*i
print(a)
Great! But it does not work for a=0 (i.e. 0! = 1)
Solution (considering only positive or null values of a):
a = int(input("Enter any number: "))
f = 1
for i in range(1,a+1):
f *= i
print(f)
1. A code to sort the array in ascending order
alphabets = array('u', ['a', 'q', 'b', 'k', 'z', 'f'])
print(sorted(alphabets))
nums = array('i', [55, 7, 0, 65, 20, 34])
print(sorted(nums))
2. A code to find the factorial of given number
fact = array('i', [2, 5, 3, 7])
for f in fact:
print(factorial(f))
#solution 1st problem
from array import *
val=array('i',[2,10,3,4,6])
val=sorted(val, key=int)
print(val)
hey hi your code is working fine even without the ("key = int"). May I know y u place the key keyword.
Wats the use of key ?
Print(sorted(var)) will do
You are the only teacher who makes me feel that coding is not so difficult as I think.. Thank you sir
Sir whole day we eagerly wait for your quality, elaborately discussed videos but recently someday you don't upload even a single video.. Please sir at least upload two your quality videos daily 🙏🙏..
Instead of replying, our tutor gave you a 'Heart Like', I wonder 'Like' is the acceptance of your request or what....
Donate; lol. You're at the mercy of an electronic guru/sensei
He taught the for loop in arrays. What a LEGEND!
2..........
import math
x=int(input('enter the value '))
for i in range(2,x+1):
if x%i==0:
print('factorial of number is',i)
code isn't working brother!
Ascending order
array1= array('i',[34,12,45,9,78])
l= len(array1)
for i in range(l):
for j in range(i+1,l):
if array1[i]>= array1[j]:
temp = array1[i]
array1[i]=array1[j]
array1[j]=temp
for i in range(l):
print (array1[i])
Answer 2:
from array import *
val = int(input("number"))
result = 1
for x in range(1,val+1):
result*=x
print(result)
The best videos i have ever seen... U discussed every basic , which is extremely extremely extremely beneficial 😍😍... I m a beginner and also faced a lot of difficulties.. but after seeing ur vdos , now i m clear about python.. my next mission is Django... And i will follow ur videos so that I don't face any kind of difficulties...thank you sooooooooooooooo muchh🥰🥰🥰🥰🥰🥰
2.
n = int(input('Enter the number '))
count = 1
for i in range(1, n+1):
count = count * i
print(count)
wrong answer my friend
2nd assignnment:
fac = int(input("enter a number to get factorial"))
import math as m
result = m.factorial(fac)
print(result)
/////this is for loop concept for factorial
s=1;
for i in range(1,fac+1):
s=s*i
print(s)
Great work
Please make videos on the python projects
It will be very helpful to us
First:-
from array import *
values = list(array ('i',(2,5,3,7,1)
val.sort()
for i in val:
print(i)
Second:-
val=6
i=1
c=1
while i
Solution for 2.
No=5
Fact=1
For i in range(1,no+1):
Fact=fact*I
Print (fact)
from array import *
vals = array('d',[4,3,1,12])
vals=sorted(vals)
print(vals)