Solve 10 loops problem in python

preview_player
Показать описание
Welcome to chai aur code, a coding/programming dedicated channel in Hindi language. Now you can learn best of programming concepts with industry standard practical guide in Hindi language.

All source code is available at my Github account:

Instagram pe yaha paaye jaate h:

Рекомендации по теме
Комментарии
Автор

Sum of even :-
even_sum=0
N=10
for i in range(1, N+1):
If (i%2==0):
even_sum+=i
print(even_sum)

computerscience
Автор

10:10 you have actually counted the even number. In order to find the sum replace the statement sum_even += 1 with sum_even += i

yogeshchacherkar
Автор

q2 soln::

n = int(input("Enter a number: "))
sum=0
for num in range(0, n+1):
if(num%2==0):
sum+=num

print("Sum of even numbers from 0 to", n, "is", sum)

subhadeepbanerjee
Автор

def factorial(a):
mul=1
i=1
while i<=a:
mul*=i
i+=1
print(mul)


a =int(input("enter the mnumber:"))
factorial(a)
ans----5

dsairaghavsumanth
Автор

Wow! This is exactly what I was looking for. 10 loop problems in one video, perfect for practicing and mastering loop concepts in Python. Thanks for the clear explanations and concise solutions!

neamulkabiremon
Автор

thankyou for this video. related to 10th question, i extender the code where we ask the user to input string and check it. the wait time increases if inputs wrong string. and in max 5th try, the code gives "blocked" statement. code below:

import time

wait_time = 1
max_tries = 5
attempts = 1
password = "password"


while True:
user_input = input("Enter password: ")

if attempts < max_tries:
if user_input == password:
print("logged in succesfully")
break
else:
print("wrong password")

print("Attempt: ", attempts, " | wait time: ", wait_time, "seconds | max attempts: ", max_tries)
time.sleep(wait_time)
wait_time *= 2
attempts += 1
else:
print("Your are blocked. please contact branch manager")

afzalhamdulay
Автор

def sums(a):
sum_ =0
i =0
while i<=a:
sum_+=i
i+=2
print(sum_)




a =int(input("enter the number:"))
sums(a)

dsairaghavsumanth
Автор

def keep_ask(a):
a =int(a)

while a>10:
a =int(input("enter the number again:" ))
if 1<=a<=10:
print("you are in range ")


a =int(input("enter the number:"))
keep_ask(a)


ans--7

dsairaghavsumanth
Автор

def revers_string(a):
reverse =""
i =len(a)-1
while i>=0:
reverse+=a[i]
i-=1
print(reverse)


a =input("enter the string:")
revers_string(a)


ans--4

dsairaghavsumanth
Автор

Q4. Reverse string using Loop
a = "Gulab Alam"
b = len(a)-1
while b >= 0:
print(a[b])
b-=1

Using FOR Loop
x = "Tarun"
y = " "
for i in x:
y = i + y
print(y)

gulabalam
Автор

3 -- >
num = 5
for i in range(1, 11):
if i == 5:
continue
print(f"{num} x {i} = ", num * i)

Airman.programer
Автор

def mul_n(a):
i=1
while i<=10:
if i==5:
i+=1
continue

print(f"{a} X {i} ", i*a)
i+=1


a =int(input("enter the number:"))
mul_n(a)



ans---3

dsairaghavsumanth
Автор

# Problem: Print the multiplication table for a given number up to 10, but skip the fifth iteration.

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

for i in range(1, 11):
if(i==5):
continue
print("{} * {} = {}".format(n, i, (n*i)))

subhadeepbanerjee
Автор

Count Positive Number
Using While Loop
num = [1, -2, 3, -4, 5, 6, -7, -8, 9, 10]
i = 0
postive_num = 0
while i < len(num):
if num[i] > 0:
postive_num+=1
i+=1
print("Final Count:", postive_num)


Using For Loop
num = [1, -2, 3, -4, 5, 6, -7, -8, 9, 10]
postive_num1 = 0
for i in num:
if i > 0:
postive_num1+=1
print("Count of Positive Number:", postive_num1)

Using List Comprehensive
p= [i for i in num if i > 0]
print("Positive Number in List:", len(p))

gulabalam
Автор

Multiplication Table Printer (upto 10, but skip 5th iteration)
Using For Loop
n = int(input("Enter the number: "))
for i in range (1, 11):
if i == 5:
continue
print(n, "*", i, "=", n*i)


Using While Loop
i = 1
num = 7
while i <=10:
if i == 5:
i+=1
continue
print(num, "*", i, "=", num*i)
i+=1

gulabalam
Автор

#Factorial Using While Loop
n = int(input("Enter Number which to be factorial: ")) i=1
while_fact = 1
while i <=n:
while_fact*=i
i+=1
print(f"Factorial of {n} is:", while_fact)

gulabalam
Автор

numb = 5
factorial = 1

# while numb > 0:
# factorial = factorial * numb
# numb = numb -1
# print(factorial)

for i in range(numb):
factorial = factorial * (i+1)
print(factorial)

Airman.programer
Автор

Question: 7-
while True:
number=int(input("please enter the number between 1 and 10 :"))
if 1<=number<=10:
print("thanks")
break
else:
print("Invalid number, please enter the valid number")

AmitKumar-mwjn
Автор

The video covers solving 10 loops problems in Python, including understanding factorial, prime numbers, and input validation. It emphasizes the importance of wait times for system response and user experience, as well as the use of conditional checks for verifying uniqueness and avoiding duplicates in loops.

00:00
Understanding Loops and Iteration in Python
05:53
Understanding Loops and Iterations in Programming
11:48
Learning Python Programming: Looping and Reversing Strings
11:48Understanding the process of printing a table and complicated math for loops.
13:05Learning about conditional checks, detecting the fifth iteration, and using the 'continue' keyword.
15:26Exploring reverse string using loops and understanding the process of character swapping.
17:45
Optimizing String Manipulation and Looping in Python
23:41
Understanding Factorial Calculation Using While Loop in Python
29:34
Understanding Prime Numbers and Validating Solutions
35:28
Understanding Prime Numbers and Unique Items in Python
41:23
Understanding Unique Items and Conditional Checks
47:16
Understanding Sleep Time and System Response in Python Programming

zorctcv
Автор

Hitesh sir tons of love from Nepal you are just amazing, the effort, the content and ofCourse the quality education no one can match your level

theupdatedworld