0% found this document useful (0 votes)
24 views

Python Assignment 7

Uploaded by

PAVAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Python Assignment 7

Uploaded by

PAVAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

1132220561

Pavan Dange

#Q1

def factorial(n):

if n == 0 or n == 1:

return 1

else:

return n * factorial(n - 1)

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

result = factorial(number)

print(result, "is the factorial")

#2

for i in range(11):

if i in [3, 5, 7]:

continue

print(i)

#Q3

for i in range(11):

if i in [3, 5, 7]:

continue

print(i)

#Q4
for i in range(-10, 0):

print(i)

print("Successfully Done")

#Q5

def is_prime(n):

if n <= 1:

return False

for i in range(2, int(n**0.5) + 1):

if n % i == 0:

return False

return True

for num in range(1, 101):

if is_prime(num):

print(num)

#Q6

a = int(input("Enter the first side of the triangle: "))

b = int(input("Enter the second side of the triangle: "))

c = int(input("Enter the third side of the triangle: "))

if a == b == c:

print("The triangle is Equilateral")

elif a == b or b == c or c == a:

print("The triangle is Isosceles")

else:
print("The triangle is Scalene")

#Q7

a = int(input("Enter the first side of the triangle: "))

b = int(input("Enter the second side of the triangle: "))

c = int(input("Enter the third side of the triangle: "))

if a == b == c:

print("The triangle is Equilateral")

elif a == b or b == c or c == a:

print("The triangle is Isosceles")

else:

print("The triangle is Scalene")

#Q8

user_input = input("Enter a string: ")

str_upper = user_input.upper()

str_lower = user_input.lower()

print("Uppercase:", str_upper)

print("Lowercase:", str_lower)

#9

user_input = input("Enter a string: ")

lowercase = ''.join([char for char in user_input if char.islower()])

uppercase = ''.join([char for char in user_input if char.isupper()])


arranged_string = lowercase + uppercase

print("Arranged string:", arranged_string)

#10

user_input = input("Enter a string: ")

letters = sum(char.isalpha() for char in user_input)

digits = sum(char.isdigit() for char in user_input)

symbols = sum(not char.isalnum() for char in user_input)

print(f"Letters: {letters}")

print(f"Digits: {digits}")

print(f"Symbols: {symbols}")

Output:

Enter a number: 7

5040 is the factorial

10

1
2

10

-10

-9

-8

-7

-6

-5

-4

-3

-2

-1

Successfully Done

11

13

17

19

23

29

31

37
41

43

47

53

59

61

67

71

73

79

83

89

97

Enter the first side of the triangle: 4

Enter the second side of the triangle: 3

Enter the third side of the triangle: 2

The triangle is Scalene

Enter the first side of the triangle: 2

Enter the second side of the triangle: 5

Enter the third side of the triangle: 6

The triangle is Scalene

Enter a string: bvb

Uppercase: BVB

Lowercase: bvb

Enter a string: pavan

Arranged string: pavan

Enter a string: hhoo

Letters: 4

Digits: 0
Symbols: 0

PS C:\Users\pavan> python -u "C:\Users\pavan\AppData\Local\Temp\tempCodeRunnerFile.python"

11111

2222

333

44

55555

5555

555

55

012345

01234

0123

012

01

333

55555

7777777

999999999

24

369

4 8 12 16

5 10 15 20 25

6 12 18 24 30 36
7 14 21 28 35 42 49

8 16 24 32 40 48 56 64

$$$$$$$$$$$$

$$$$$ $$$$$

$$$$ $$$$

$$$ $$$

$$ $$

$ $

**

***

****

*****

****

***

**

You might also like