Repository navigation
Expand file tree
/
Copy pathfullcourse.py
More file actions
110 lines (92 loc) · 2.6 KB
/
Copy pathfullcourse.py
File metadata and controls
110 lines (92 loc) · 2.6 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
#import libary
from math import *
#simple print
print("Hello World!")
print(" /|")
print(" / |")
print(" / |")
print(" /___|")
#variable
name = "John"
age = 25
print("There once was a man name " + name + ", ")
print("he was " + str(age) + " years old.")
print("he really liked the name " + name + ", ")
print("but didn't like being " + str(age) + ".")
#new line, quote
print("first line \n second line")
print("quote\"")
#basic string function
print(name.lower())
print(name.upper())
print(name.isupper()) #return true or false if it uppercase or not
print(name.upper().isupper()) #more than one function
print(len(name)) #string lenght
print(name[0]) #return character by using index number
print(name.index("J")) #return character index number
print(name.replace("John", "Mike")) #replace word or letter (default, change)
#basic int
num1 = -5
print(abs(num1)) #return absulate number
print(pow(3, 2)) #power function
print(max(4, 6)) #return highest number between two
print(round(3.4)) #return rounded number
print(sqrt(9)) #return square root parameter number
#input
userName = input("Enter your name: ")
userAge = input("Enter your age: ")
print("Hello " + userName + "!!, your age is " + userAge)
num1 = input("Enter first number:")
num2 = input("Enter second number:")
result = float(num1) + float(num2) #convert string to int
print("Total = " + str(result))
#function
def sayHi():
print("Hello User")
sayHi()
def profile(name, age):
print("Hello " + name + " " + age)
profile("Eizlan", "22")
def cube(num):
return num*num*num
print(cube(3))
#if else
isMale = True
isTall = True
if isMale or isTall: #true if either true
print("You are a male or tall")
elif isMale and not(isTall):
print("You are short male")
else:
print("You are female")
#comparison
def maxNum(num1, num2, num3):
if num1 >= num2 and num1 >= num3:
print(num1 + " is the largest number!")
elif num2 >= num1 and num2 >= num3:
print(num2 + " is the largest number")
elif num1 == num2 and num2 != num3:
print("all the three number is the same number")
else:
print(num3 + " is the largest number")
maxNum("3","1","2")
#Dictionary
monthConversion = {
"Jan" : "January",
"Feb" : "Febuary",
"Mar" : "March",
"Apr" : "April",
"May" : "May",
"Jun" : "June",
"Jul" : "July",
"Aug" : "August",
"Sep" : "September",
"Oct" : "October",
"Dec" : "December",
}
print(monthConversion.get("Mar"))
#while loop
i = 1
while i <= 10:
print(i)
i += 1