-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
131 lines (98 loc) · 2.54 KB
/
Copy pathscript.py
File metadata and controls
131 lines (98 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# for i in range(100):
# print("hello")
# Print each character of the word "PYTHON" on a new line.
# name = "PYTHON"
# print(name[0])
# print(name[1])
# print(name[2])
# for char in name:
# print(char)
# Take a number from the user and print its multiplication table.
# num = int(input("Enter your number:"))
# print(num * 1)
# print(num * 2)
# print(num * 3)
# print(num * 4)
# range default -> 0 -> 10 (exclude)
# (1,2..9)
# for i in range(1, 13):
# print("Multiplication", num * i)
# Keep asking the user for a number and keep adding it to a total.
# Stop when they enter 0, then print the total.
# 10
# num = int(input("enter your number:"))
# total = 7
# while num != 0:
# total += num
# num = int(input("enter your number:"))
# print(total)
# Q → Print this pattern:
# *
# * *
# * * *
# * * * *
# Outer loop → controls the rows (lines)
# Inner loop → controls what gets printed in each row
# (1,2,3,4)
# outer loop -> 4 rows
# print("Vivek")
# for i in range(1, 5):
# for j in range(i):
# print("*", end=" ")
# print()
# Print 1 to 10 but stop the loop as soon as the number 5 comes.
# for i in range(1, 11):
# print(i)
# if i == 5:
# break
# print("End")
# Print 1 to 10 but skip all multiples of 3.
# 3 6 9 => don't print this
# i = 1 => 3 / 3 = 0
# for i in range(1, 11):
# if i % 3 == 0:
# continue
# print(i)
# print("End")
# for i in range(10):
# pass
# print("hello")
# Search a number from 1 to 10. Print "Found" on break,
# "Not found" from the else.
# num = int(input("Enter your number from 1 to 10:"))
# (1,... 10)
# for i in range(1, 11):
# if i == num:
# print("Found")
# break
# else:
# print("Not Found")
# if 18 > 20:
# pass
# Print the sum of the first n numbers.
# 10= 1 + 2 + 3 + 4 + 5 +6 .. + 10
# 1 + 2 + 3 + 4 = 10
# num = int(input("Enter number:"))
# sum = 0
# for i in range(1, num + 1):
# sum += i
# print(sum)
# Reverse a number: 1234 → 4321.
# reverse * 10 + lastDigit
# reverse * 10 + lastDigit => 0 * 10 + 4 = 0 + 4 = 4 * 10 + 3 = 40 + 3 = 43 * 10 + 2 = 430 + 2 = 4321
# num = int(input("Enter your number"))
# reverse = 0
# while num > 0:
# lastDigit = num % 10
# reverse = reverse * 10 + lastDigit
# num //= 10
# print(reverse)
# Count the vowels in a word entered by the user.
# "aeiou"
# name = input("enter your name:").lower()
# print(name)
# count = 0
# for char in name:
# if char in "aeiou":
# count += 1
# print("Number of vowels",count)